- Home /
Question by
gatzkerob · Jan 22, 2020 at 06:10 PM ·
positionaxiscoordinateslocal
Move object to position on another object's locally rotated axis
I created a cube and rotated it locally -90 degrees on its Y axis
So its local X axis is now the world's Z axis
I want to align another world space object along the cube's local X axis
I've tried TransformPoint()
among other things, but not getting the desired result.
Is there some trigonometry involved with doing this, or is there a built-in function?
Cheers.
Comment
Answer by gatzkerob · Jan 22, 2020 at 06:39 PM
To answer my own question:
secondObject.transform.position = transform.position + transform.TransformDirection(new Vector3(1, 0, 0));
This will keep the second object on the local X axis of the locally rotated object.