Keeping a Constant Z Position

Hi, all! I have a shadow projector situated above my character. I would like it to copy my character’s x and y positions, but not its Z position.

For some odd reason this code does NOT work. What’s wrong with it? Thanks!

Cheers- Young

var follow : GameObject;
var right = follow.transform.right;
var forward = follow.transform.forward;
var up = follow.transform.up;

function Update () {

	transform.position = (right,forward,3);


function Update () {
right = follow.transform.right;
forward = follow.transform.forward;
up = follow.transform.up;
transform.position = (right,forward,3);

Transform.right and so on are directions, you’re not looking at the position at all. (Plus you’re only storing the directions once instead of every frame, although you don’t actually want them anyway.)

var objectToFollow : Transform;

function LateUpdate () {
	transform.position = Vector3(objectToFollow.position.x, transform.position.y, objectToFollow.position.z);

This code should not even compile! right and forward are Vector3, and 3 is an int!

If you want your projector to follow the follow object at 3 units above, you should use:

var follow: GameObject;

function Update(){

    var pos: Vector3 = follow.transform.position;
    pos.y += 3;
    transform.positon = pos;