- Home /
mirror object based on parent transform
I have two spheres, children of an empty parent object. I am moving one object and want the other to follow the movement in reverse.
This is working based on world coordinate - how to I make it work based on the parent objects coordinates?
function moveOtherHandle()
{
newPosition = transform.position;
otherHandle.position = -newPosition;
}
Comment
A mirror transformation does not mean that you invert all coordinates. You only need to invert one local coordinate (normal to the plan defined by the mirror).
So you need the mirror plan coordinates (i suppose the mirror is your parent object ?)
Answer by robertbu · Apr 26, 2013 at 03:22 PM
Assuming the code above does what you want in global space you can use Transform.localPosition:
function moveOtherHandle()
{
newPosition = transform.localPosition;
otherHandle.localPosition = -newPosition;
}