Forum rules - please read before posting.

Cinemachine Deadzones & shifting sideways/around First Person Player

edited September 2023 in Engine development

Hi,

I'm using the First Person Camera, and wanted to have a Flashlight that moves around, before the Player looks.

I've set up Cinemachine deadzones and it's almost there, but the Player Camera slightly shifts sideways and i'm trying to mitigate that.

It should do that but from a fixed POV, the camera shouldn't sway left and right, when looking around.

Here's a Video of it:
https://streamable.com/q6qnj0

https://i.ibb.co/LxRLtHz/camera.jpg

I have already learned, that it probably has to do with the Parent Object, and how the Camera is nested, because i've managed to get it to work with a Blank Project without AC and the First Person Starter Asset from Unity, where the Camera is outside of the Player Hierarchy.

Putting in the parent Objects into the "follow" field in the CM Virtual Camera, didn't change the behaviour.

I have also tried putting the CMCamera either on the First Person Camera, or the MainCamera, both behave the same way.

How could i set it up differently, or is there an option to mitigate that shifting behaviour?

AC Version: 1.78.4
Unity: 2022.3.8f1

Comments

  • Is the use of Cinemachine here is purely for the motion of the torch, or is it being used to render the camera as well?

    AC will control the First Person Camera object's Transform in the Update loop. You could try setting the CM Brain's "Update Mode" to Late Update, so that it runs afterwards.

    I have already learned, that it probably has to do with the Parent Object, and how the Camera is nested, because i've managed to get it to work with a Blank Project without AC and the First Person Starter Asset from Unity, where the Camera is outside of the Player Hierarchy.

    If this is the case, and the above doesn't work, then you could try referring to an empty GameObject outside of the Player's Hierarchy, which each frame copies the position/rotation of the FP Camera (which does need to be a child of the Player):

    using UnityEngine;
    using AC;
    
    public class SnapToFPCamera : MonoBehaviour
    {
    
        void Update ()
        {
            FirstPersonCamera fpCamera = Object.FindObjectOfType<FirstPersonCamera> ();
            transform.position = fpCamera.transform.position;
            transform.rotation = fpCamera.transform.rotation;
        }
    
    }
    
  • Thank you so much, i was trying for over a week now. It's like magic, it just works.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.