Search Unity

Cinemachine : follow & confiner & instant spawn

Discussion in 'Cinemachine' started by ABerlemont, Mar 2, 2020.

  1. ABerlemont

    ABerlemont

    Joined:
    Sep 27, 2012
    Posts:
    67
    Hey there,

    I have a camera that follows an avatar and that is confined within the game space (using CinemachineConfiner).

    On startup the camera manage to instantly spawn above the target (using the PreviousStateIdValid property) but then is panning to solve the confinement requirements. And I would love to be able to tell the camera to instant solve that panning (so that the camera is at the final state when the player see the first ingame frame).

    PreviousStateIsValid seems to not communicate with the confiner.

    Any idea ?

    Thanks for the help !
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,728
    If you change the geometry of the confining shape at runtime, the confiner will not automatically detect that. You have to call confiner.InvalidatePathCache()
     
    theProject likes this.
  3. ABerlemont

    ABerlemont

    Joined:
    Sep 27, 2012
    Posts:
    67
    Hey Gregoryl !

    I'm not changing the confiner shape at runtime. Everything is setup before play mode.

    What is not setup is the camera position and the follow target.
    - Follow target is spawn at a starting point (that varies between levels)
    - Then camera is spawn above that target
    - Because the target can spawn in corner of the level the camera will need to pan for a few seconds because of the confiner behavior.

    Is there any way to tell cinemachine to instantly solve final position of whatever the confiner behavior is guiding the camera toward ? (Somewhat like cinemachine is doing using PreviousStateIdValid for target following).

    Thanks !
     
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,728
    It should already do that. Why is the camera panning? Can you show the inspector your your vcam, with the confiner?
     
  5. ABerlemont

    ABerlemont

    Joined:
    Sep 27, 2012
    Posts:
    67
  6. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,728
    Interesting. I don't see where the panning is coming from. You have no damping in the confiner, so its effect should be immediate.

    Is it possible that another vcam is initially active, and you are blending from it?

    Can you show me a video of the problem?

    nb. the FollowZoom probably shouldn't be there, as it's meant for perspective cameras. You should remove it.
     
  7. ABerlemont

    ABerlemont

    Joined:
    Sep 27, 2012
    Posts:
    67
    Thanks for the confirmation. I'll first re-write my integration just in case I did something wrong (and remove that follow zoom stuff). Hopefully it wasn't something overriding cinemachine behavior somehow :shrug:
    I'll keep you posted and I'll make a video then.

    Thanks for the insights !
     
  8. ABerlemont

    ABerlemont

    Joined:
    Sep 27, 2012
    Posts:
    67
    The problem came from custom blendings.

    @Gregoryl
    You pointed the solution when you said that another vcam was active. I have something that de-enabled the component but it's still active for cinemachine ("live" mention)

    Thanks for the help !
     
    Gregoryl likes this.