- Home /
Third person camera; player rotation.
So, I'm trying to make something simular to what you would see in any type of action combat game, I've actually gotten pretty far in my development, but my camera has always been.... well... less than functional.
I have a cross-hair on the center of my screen, and basically what I want it to do is to have the player follow the mouse around, by rotation. The problem with this is that the only way I understand how to do it is to have the player rotate towards the mouse...
This works, but the problem is the player will never stop rotating, the reason for this is because the mouse stays in the same spot, and the player endlessly tries to play a game of catch.
Here's a video of the type of "Mouse follow" functionality I'm trying to achieve.
Answer by mwbranna · Oct 14, 2014 at 07:56 PM
If the camera is a child of the player, then the player should never try to turn toward the camera.
If the player turns, it will also move the camera so the angle between their forward vectors doesn't actually change - you will just spin.
The default mouse orbit script is intended to be put on a camera that is not a child of the object it is looking at. The script just modifies the cameras location based on your character's location to get the same effect as parenting but keeping the rotations independent.
The overall setup I'd do (may not be the best implementation but it would work) to achieve the setup in the video above would be:
independent (not child of player) camera with MouseOrbit script
player's rotation copies camera's rotation (with y direction zero'd)
if you want the player model to turn relative to the camera, use animations but keep the actual "forward" vector for the player the same as the camera's