Copy object rotation based on alignment in Unity
I have two boxes. BoxB is placed in front of BoxA. When i rotate BoxB it should copy the rotation to BoxA.
This is a simple task:
boxB.transorm.rotation = boxA.transform.rotation;
But i only want to rotate BoxA on the z axis. And only alongside the BoxB axis that is looking towards BoxA.
Imagine a cube in your hand and a rectangle printed onto the wall. Move the cube in front of your eye so that it aligns with the rectangle on the wall. When you rotate the cube, the rectangle follows. This sould work regardless of the cubes local rotation.
Your answer
Follow this Question
Related Questions
Rotate camera on collision of character 1 Answer
Cancel out the steering rotation returned from a wheel colliders .GetWorldPose(out pos, out rot); 1 Answer
Space/Aircraft rotation 0 Answers
Camera Controller script as a child object,Camera Control as a Child Object for my Player 0 Answers
Object Rotation With Touch 0 Answers