If it want OBJ1 to always get OBJ2’s position. What is the best way to do it?
A. make OBJ1 a child of OBJ2.
B. Put a script on OBJ1 with the following code:
void Update()
{
transform.position = OBJ2.transform.position;
}
note, I do NOT want OBJ1 to get the Rotation of OBJ2… ONLY the position… and i dont want to fake it by useing a third object or freeze rotation on the rigidbody.
yeah, putting it as child won’t work for me since OBJ1 is a camera and OBJ2 is a ball that gets angular velocity… If the cam is a child of the ball its gonna get the ball’s rotation too… so i used the script to make the camera follow the ball… but my friend says its a horrible thing to do in the matter of efficiency.
I dont want to make the camera follow an empty object that contains the ball and doesnt have rotation because then the ball’s physics won’t effect the parent empty object.
Is it possible to put the camera as a child of a rotation object and not get his rotation? (Btw, camera has mouse look too)
For one object, there’s no issue of efficiency. Do it the simplest and most maintainable way for you in the long run; don’t hack it in the name of performance for this.
EDIT: however, you may want to use LateUpdate in this case: Unity - Scripting API: MonoBehaviour.LateUpdate()
thanks, will do it in LateUpdate 