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.

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.