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);
}
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);
}