Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Recenter won't work immediately upon launching

Discussion in 'Cinemachine' started by Big_Friggin_Al, Jun 2, 2020.

  1. Big_Friggin_Al

    Big_Friggin_Al

    Joined:
    Jan 9, 2014
    Posts:
    36
    I have a freelook camera set up, all works great, and I'm using World Space binding mode.

    Only problem is that I want to start the game with 'recenter to target heading' functioning, so that if the player turns their character immediately on starting gameplay, the camera will follow their turn.

    This does not work. Instead, it seems that I have to wait the 'Wait TIme' interval once, at the very start of game running, and then recenter will 'kick in' and work all the time after that.

    I've tried using the 'recenterNow()' call but it doesn't do anything during this initial wait time interval, though it DOES work every time I call it after that (bound to a key).

    Have tried starting with a wait time of 0, and then it follows player right off the bat, but I don't actually want a wait time of 0 (want more like 3 seconds). Have also tried setting it to 0 in the inspector and then changing it to 3 in Start(), but then I get the same problem initially described.

    Can't figure this one out, is there a setting I'm missing or something?
     
  2. gaborkb

    gaborkb

    Unity Technologies

    Joined:
    Nov 7, 2019
    Posts:
    856
    I am not sure I understand the problem. Could you elaborate a bit more?
    If I enable recenter to target heading with wait time 2, then my Freelook camera starts in the centered position right away, and I can also move the camera around right away.

    What version of Cinemachine are you using?
     
    Last edited: Jun 2, 2020
  3. Big_Friggin_Al

    Big_Friggin_Al

    Joined:
    Jan 9, 2014
    Posts:
    36
    Ok yeah mine definitely doesn't do what you're describing.

    So if I have my recenter to target heading wait time set to 3 seconds, the sequence goes:

    -Enter play mode
    -freelook cam is NOT recentering for first 3 seconds of gameplay, that is it remains pointing 'due north' or whatever way it was facing before I entered play mode, regardless of which way the player moves/turns
    -during this initial 3 seconds, pressing a key bound to recenterNow() does nothing (this is also the case if I manually rotate the camera and then hit the key bound to recenterNow() during the initial 3 seconds)
    -after the initial 3 seconds, the camera recenters and REMAINS recentered, following the player moving and turning, from then on
    -after the initial 3 seconds, I can rotate the camera with right stick and hit the key bound to recenterNow() and the camera instantly recenters, as expected

    I am using cinemachine 2.5.0, with unity 2019.3.6f1

    Has anyone else encountered this?
     
  4. gaborkb

    gaborkb

    Unity Technologies

    Joined:
    Nov 7, 2019
    Posts:
    856
    Could you send some screenshots of your Freelook setup (both object hierarchy and inspector views)?
     
  5. Big_Friggin_Al

    Big_Friggin_Al

    Joined:
    Jan 9, 2014
    Posts:
    36
    I can grab those tonight, sure. I know the camera is currently a child of the player gameobject though, is that how it's supposed to be?
     
  6. gaborkb

    gaborkb

    Unity Technologies

    Joined:
    Nov 7, 2019
    Posts:
    856
    No, that could very well by the cause of the problem. Why? Because your player gameobject moves around, thus modifying your vcam's transform indirectly through the transform hierarchy. Dog chasing its tail situation.

    Have a look at our example scenes. You can get them in the package manager.
     
  7. Big_Friggin_Al

    Big_Friggin_Al

    Joined:
    Jan 9, 2014
    Posts:
    36
    Right, ok I'll try changing that tonight. Is it recommended to have it be just a child of an empty 'vCams' object in the root of the hierarchy instead?
     
  8. gaborkb

    gaborkb

    Unity Technologies

    Joined:
    Nov 7, 2019
    Posts:
    856
    Yes, that's a good way to keep your Hierarchy clean. :)
     
  9. Big_Friggin_Al

    Big_Friggin_Al

    Joined:
    Jan 9, 2014
    Posts:
    36
    Same behavior with camera parented to empty object, unfortunately.

    Here's my cam setup, as requested:

    Screen Shot 2020-06-05 at 1.15.08 AM.png Screen Shot 2020-06-05 at 1.15.50 AM.png Screen Shot 2020-06-05 at 1.16.08 AM.png Screen Shot 2020-06-05 at 1.16.16 AM.png Screen Shot 2020-06-05 at 1.18.37 AM.png