I have a game which gets as input the degrees of rotation around the z axis that the game’s camera should have. If I want the game to rotate around the center point I can add a script to the camera with the following code.
However, I don’t want the camera to rotate around the center, but around a given point. I’m aware of rotateAround, but it’s not what I’m looking for since I don’t want to perform a rotation on the camera to get a new euler angle. I already know the angle and just want to set it. What is the best way to do this?
Thanks to everyone who answered, but unfortunately none of the previous answers worked correctly on my device. I ended up finding this solution:
Calculate translation from camera center to pivot point
Translate camera to pivot point
Set camera euler angles to zero
Rotate camera by the given degrees
Translate camera back to original position (negative of the translation calculated in the first step)