- Home /
Rotating Camera for Combat?
So I wanted to go for an effect like this: https://www.youtube.com/watch?v=9IGUb0LMx9w
If you watch the video, you'll see that the camera is behind the player and faces the enemy.
I know what you're thinking, parent the camera to the player, set it's position behind the player, and make it always face the enemy with a simple Quaternion.Lerp script.
Well, the problem with that is that when the player turned to the right or left or backwards, the camera jumped to the left, right, and forwards of the player, respectively.
So what I am looking for is a script that will make the camera ALWAYS behind the player with respect to the enemy, regardless of what direction the player is facing.
Thank you in advance.
Answer by Cherno · Sep 20, 2015 at 08:52 PM
The video you linked seems to be a special case; note how the player always faces the enemy, not only the camera.
Anyway, making the camera a child of the player is not the way to go here. Make it follow the player's position (with an offset so it sits above and behind him/her) using Vector3.Lerp, and use Transform.LookAt or similar to always face the enemy. for the first pat, take a look at the SmoothFollow cscript included with the Standard Assets (although it really only requires one line of code).