1
\$\begingroup\$

I'm using Unity (2019.4.11.f1, HDRP).
My goal is to create a first-person POV camera.

To this purpose, I tied a Cinemachine (2.7.3) Virtual Camera to the head of a third person player character (one from the Basic Locomotion demo of this asset).
The Body of the camera is set to 'Hard Lock to Target', Aim to 'POV', and Recenter Target to 'Follow Target Forward'. This works fine.

The camera has a Horizontal Axis Value Range (-# to #), that limits the rotation of the camera, but I cannot figure out how to tie this to the rotation of the Follow component (the head of the avatar).
When I walk my character around, the camera can only rotate within the set Value Range angle that has it's 0-point in one absolute direction (let's say north), independent of the player's orientation.
It seems to use World Orientation, but I don't know and wasn't able to find out where to change that.

Does anyone know how I can change this behaviour?

\$\endgroup\$
0
\$\begingroup\$

I was figuring out a first person controller and had a similar problem. This is what worked for me, I think it should help but I may be misunderstanding, or there may be a better way.

First, you didn't specify where the vcam is in the hierarchy. I'm assuming its at the root level, which would explain why it's using world space orientation. If it was a child of the character's head, it should behave according to that local space.

Body should probably be set to "do nothing" if you don't want the vcam to control its own movement. I think "hard lock to target" emulates the effect of having the camera attached to the target, but doesn't actually put the camera into the target's local coordinate system. Again, that seems likely to be the cause of your problem.

Second, the POV component allows the player to control the camera, but what you actually want the player to be doing is controlling the character. In other words, you don't want the camera to be able to move farther than the character can turn, or to mis-match between where the head and camera are. You can certainly make it work but you'll have a complicated setup that'll be difficult to tweak, just to achieve a simple effect.

So the easiest solution is to set up your character controller (I used the Unity Standard Assets one and modified that) and just attach a virtual camera set to "do nothing" where the camera would normally be. Then you can still use all the cinemachine features to switch cameras and whatnot as normal.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .