- Home /
a child object that inherits only position from parent
hi my friends , i just want to ask for either one of the following:
1-i want a child object to get effected by its parent movement but only its position , not scale or rotation.
2-or i want a normal object to move (always) to the center of another object (and it will be great if it does not lag or shutter doing so).
thanks for any help i get.
Answer by aldonaletto · Nov 18, 2011 at 11:51 PM
You should use the second alternative: just copy the transform.position of the "parent" to the "child" object. To ensure there will be no lag, you should copy it in LateUpdate to be sure that the "parent" object have been already moved in Update:
var target: Transform;
function LateUpdate(){ transform.position = target.position; }
Answer by syclamoth · Nov 18, 2011 at 11:50 PM
Number two-
transform.position = myParent.position;
make sure you call this before anything that would move the parent. It works, but it sometimes seems to lag because of excecution order issues.