How to rotate object using another object's axes?
I have a quaternion that I want to apply to an object, but I don't want to rotate in world or self space, instead using another object's axes, in this case the camera, eg: if the rotation was Quaternion.Euler(0, 180, 0) it would rotate 180 degrees about the camera's y axis. I can't see any way to do this, unless it's applying multiple RotateAround functions around each of the camera's axes, but that doesn't seem right. What would be the best way to go about rotating an object relative to another's axes?
Answer by dan_wipf · Mar 27, 2019 at 06:51 AM
i guess, what you are looking for is this: public void RotateAround(Vector3 point, Vector3 axis, float angle);
this is used in your case like this:
transform.RotateAround(Camera.main.transform.position,Vector3.up,180);
Your answer
Follow this Question
Related Questions
How to set y rotation of an object to be z rotation of another? 1 Answer
How to use Quaternion.Slerp with transform.LookAt? 3 Answers
How can I make my game object move like this? 0 Answers
how to rotate bullet towards enemydirection? 0 Answers
Rotation on moving using virtual joystick is not working as expected in 3D game. 0 Answers