Well this should actually be pretty easy, I thought, a few days ago.
Setting up Cinemachine Free Look to have a cool Third Person Shooter Camera … well
Setup:
Pretty much standard Cinemachine Free Look
with an Cinemachine Camera Offset (to avoid aiming at the players head but over his shoulder),
Orbit-Binding-Mode set to “Lock To Target On Assign”,
Tracked Object Offset set to (0 , 1.4 , 0) on all three rigs as my character-origin is at the feet.
What are the problems:
- Move on Mouse Input
Well, it’s a shooter, so I need pretty direct control over the camera rotation based on the player input - I tried everything on the Axis Control
- setting the accel and decel Time to 0 = jerky movement
- setting them to small numbers = jerky movement
- setting them to higher valus = indirect control + deceleration movement after the physical mouse movement has stopped
- setting only the decel Time to 0 = jerky movement
- setting the mouse Input with the old InputSystem or setting it with the new InputSystem results in a somewhat direct control = jerky movement, it stops, then acclerates, stops, acclerates again.
code:
private void Awake()
{
CinemachineCore.GetInputAxis = GetAxisCustom2;
}
public float GetAxisCustom2(string axisName)
{
input_view = Mouse.current.delta.ReadValue() * sensitivity;
if (axisName == "Mouse X")
{
//return Input.GetAxis("Mouse X");
return input_view.x;
}
else if (axisName == "Mouse Y")
{
//return Input.GetAxis("Mouse Y");
return input_view.y;
}
return 0;
}
jerky movement == from complete jumps (as if the camera teleports in position or rotation) to unconsistent movement/rotation behavior - as if someone is driving the camera, like he’s driving a car for the first time, hard breaks, putting in the reverse gear while moving forward, starting slow and then suddenly switching to full throttle and so on.
- Rotation of the Camera (without any Mouse-Input)
No matter what settings I change, the camera always tries to look at the player-movement direction.
Lookahead time is set to zero, Orbit-Binding-Mode set to “Lock To Target On Assign” - but when the player moves sidewards, the camera stays in place for a while, tries to look at the player, which is restriced by the Orbit-Binding-Mode, so it starts to rotate torwards the player and then look forward again in something like a sine-curve with high frequence. Every 0.3f seconds or so, it changes it’s mind and looks either forward as it should or to the player.
When I don’t move the Mouse, the camera should not rotate, just move with the player.
This makes aiming impossible.
Now I don’t want to give up on Cinemachine as it comes with some handy features and my own Camera-Monobehaviour jitters slightly and feels like the mouse-position is restrained to a grid (which probably happens because of setting the localEulerAngles or even the input itself).
At this point you might guess my mouse is broken, but it works in every Ego-Shooter / ThirdPersonShooter I bought on Steam - just not in my own games.
Is there a way to fix these problems? Am I missing something? I’ve read throught articles, forum posts, Unity Answers and watched almost every Youtube Tutorial on that topic.
Maybe I should mention that I am not a beginner, I work with Unity since more than 6 years (mostly on FPS-Games).
Example Video: