How To Make An Object Stay Somewhere Relative To Another Object

This may have already been discussed, but here we go anyway. I have this code right here:

 #pragma strict

 public var target : Transform;
 
 function Update () {
     transform.rotation.x = target.rotation.x;
     transform.rotation.y = target.rotation.y;
     transform.rotation.z = target.rotation.z; 
     transform.position = target.position + target.position(-3,-1,0);
 }

This code rotates it properly, but it just stays in place, instead of following a point on “target”. BTW, “it” is the object the script belongs to, and the “target” is an object that rotates a bunch. If you could help, it would much be appreciated.

Thanks,

Fahim,

Try doing it this way instead.

transform.position = new Vector3(target.position.x - 3f, target.position.y - 1f, transform.position.z)

If you are in 3d game make sure its not moving along Z axis.