Orbiting camera 90 degrees around a 2D billboard character

I can’t seem to find a way to orbit the camera around the player. It is a billboard logic 2d sprite. When the player presses either arrow key, the camera orbits 90 degrees to left or right (depending on which key he/she pressed). How can I do this? Here’s a paint illustration about the idea (black ball being the player, arrows being the camera movement):
1379987--70158--$7oITJWC.png

Maybe parent the camera to an empty object and then rotate the empty with a lerp 90 degrees when the key was pressed.

Thank you, works fine now. What about making it smooth? At the current state it just changes it’s rotation by 90 degrees everytime player uses arrow keys.

this.transform.eulerAngles = Vector3.Lerp(Camera.main.transform.eulerAngles, new Vector3(0, leftTarget, 0), Time.deltaTime * speed);
leftTarget = leftTarget + 90F;

LeftTarget is the amount the camera moves left. This code is triggered if the player pressed the left arrowkey.

Because you are dealing with rotation, you have to use a quaternion lerp. I did something similar in your project to smooth out the rotation of the player. It has to be in the update because it makes gradual changes.
Although, if that rotated for you, maybe I’m wrong about that, but anyway, lerp is supposed to smooth it out so something is wrong.

Could you give me a pseudocode or something? I’m quite a noob when it comes to quaternions.

I think this might help:

I’m sure you will figure it out.

Still can’t. And by smoothing, I mean like it orbits, like in the picture. At the current state, when you press the key once, it instantly goes left by 90 degrees (or right, if you pressed that key).

If it does that, then lerp isn’t working, because lerp divides the rotation into itty bitty chunks and changes the position as it moves in the update function. You give it the start rotation, the final rotation, and the amount you want it to move each time. I used it on your character turn to smooth it out, so you have an example there. There is an example in the script reference for quaternion lerp. Maybe just experiment with the function outside of your project and get it to do a turn. I had to play around before I got it working on your character, which was the first time I used it. You will probably have to use a bool for when it’s supposed to lerp and use a keyup rather than down to change the bool. When it’s at it’s final position, then you would change the bool to false, so it’s ready for the next rotation.

Make sure speed is a low value? If Time.deltaTime * speed is over 1.0, it rotate instantly like you describe