x


Blob Shadow

Ok, how can I make my blob shadow that was included with the unity package follow the player and not to rotate with it, I want it to follow the shape according to the terrain. How can I do that.

  • Felipe
more ▼

asked Feb 04 '12 at 08:33 PM

BigBlob gravatar image

BigBlob
340 37 62 66

what do you mean by follow it but not rotate with it. Do you want it to be vertically above the character looking down on it the whole time or... What?

Feb 04 '12 at 09:54 PM DGArtistsInc

Its becuase my character is rolling ball and if a shadow is a child of the ball then obviously it will rotate with it too

Jun 27 '12 at 07:04 PM BigBlob
(comments are locked)
10|3000 characters needed characters left

3 answers: sort voted first

Ok I don't know how the hell that other script is supposed to function, but here's mine.

The "5f" value affects how high above the ball the shadow projector is, you can change it to whatever you like, it affects how much the size of the shadow changes with distance from floor. Actually the commented out code is the original "transform.position = transform.parent.position + Vector3.up * 15f;"

Make sure the projector is a child of the ball.

//BlobShadowController.cs

using UnityEngine;
using System.Collections;

public class BlobShadowController : MonoBehaviour
{
    void Update()
    {                                        
        transform.position = transform.parent.position + Vector3.up * transform.parent.localScale.y * 5f;//* .50f;
//   transform.position = transform.parent.position + Vector3.up * 15f;
//   Debug.Log(transform.position);
        transform.rotation = Quaternion.LookRotation(-Vector3.up, transform.parent.forward);
    }
}
more ▼

answered Feb 13 at 04:39 AM

luniac gravatar image

luniac
52 6 16 23

(comments are locked)
10|3000 characters needed characters left

The easiest thing to do is just parent the player to the blob shadow. That is place the blob where you want it relative to your object, then make it a child of the object. Then whenever you move the character, the shadow will follow.

more ▼

answered Feb 04 '12 at 11:09 PM

Peter G gravatar image

Peter G
15k 16 44 136

Thaks but i wnat it to move the shadow with the player but not to rotate with it

Feb 04 '12 at 11:56 PM BigBlob
(comments are locked)
10|3000 characters needed characters left

I had exactly this problem, but I was able to put together a robust solution based on various community answers. I think it will work for you.

Create a blob shadow projector (I think one comes in standard assets). Then slap this script on it. Once you point the variables to the player and the sun/light source in the inspector, it will work like a charm.


// ShadowFollow.js

#pragma strict

var objectToFollow : Transform; // The object you need a shadow under

var offset : Vector3; // How much to shift the projector from the object center

var lightSource : Light; // What light is "casting" the shadow

function Start () {

transform.rotation = lightSource.transform.rotation;

}

function Update () {

transform.position = objectToFollow.position + offset;

}

more ▼

answered May 24 '12 at 04:04 PM

ActionScripter gravatar image

ActionScripter
15 1 3

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x808
x217
x28

asked: Feb 04 '12 at 08:33 PM

Seen: 2046 times

Last Updated: Feb 13 at 04:42 AM