Camera and Shadow Following Ball

Hi everyone, I’m fairly new to Unity, have been using it for about 3 weeks now, though I haven’t started scripting yet. Anyway, I’m having a really frustrating problem when I’m using blob-shadows on my ball, as well as a following camera, more details below.

Ok, I have set up a scene with a ball, a blob shadow (attached to the ball), a camera (also attached to the ball) and of course a surface which the ball is positioned on.

My problem is that I want to lock the axis for the shadow, and make the projection face straight down all the time. But since I have attached it to the ball (as a child), the shadow rotates together with the ball when it starts rolling. This looks really strange and I want to know if there is any way to lock the axis and make it make it face down.

My other problem is pretty much the same as the previous except that it’s the camera this time, I want the camera to follow the ball top down but, the same thing here, since I have attached the camera to the ball (again, as a child), it rotates with the ball when it starts rolling.

I can imagine that I need to script some to make this work out, now I only need to know what I need to script.

Please, if someone out there have a solution, care to share it with me? :slight_smile:

Happy developing!

Don’t make the shadow a child; instead use a script that makes the shadow follow the position of the ball.

–Eric

I actually tried to do do that now, but how do I tell the shadow to position itself at the ball? I need to record the position of the ball first don’t I?

A script I’ve used for this before:

var objectToFollow : Transform;
var offset : Vector3;

function Update () {
	transform.position = objectToFollow.position + offset;
}

–Eric

Wow, thanks, it works perfectly.

From what I understand, the line:

var objectToFollow : Transform;

Declares a variable for the object that the object holding the script should follow?

and the line:

var offset : Vector3;

I’m not really sure about, but creates a vector which determines the distance of the object offset?

Then this part:

function Update () {
   transform.position = objectToFollow.position + offset;
}

It updates the game with the new position with addition of the offset value?

If I’m all wrong, correct me please? And thanks again, this sure will come in handy. :slight_smile: