Search Unity

Question [Resolved] Reset virtual camera on respawn or reload

Discussion in 'Cinemachine' started by MineCode27, Nov 10, 2021.

  1. MineCode27

    MineCode27

    Joined:
    Dec 27, 2013
    Posts:
    9
    Hi,

    I need some help with camera reset on player respawn or load game form save. I'm using camera with body set to Framing Transposer and aim set to POV.

    When player respawn or load inside same scene I use:
    Code (CSharp):
    1. _currentVC.OnTargetObjectWarped( _currentVC.Follow, positionDelta );
    and to reset POV:
    Code (CSharp):
    1. CinemachinePOV pov = _currentVC.GetCinemachineComponent<CinemachinePOV>();
    2. if( pov )
    3. {
    4.     pov.m_HorizontalAxis.Value = player.transform.eulerAngles.y;
    5.     pov.m_VerticalAxis.Value = 0.0f;
    6. }
    7.  
    My problem is that if I use damping then camera warp will also carry that with to new location and I don't want that on respawn or reload camera do damping. Is there any way to reset damping or camera so my camera is on initial state?
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,721
    Did you try setting
    vcam.PreviousStateIsValid = false
    when the player is respawned? That will cancel all damping (so you won't need OnTargetObjectWarped).
     
    WryMim and MineCode27 like this.
  3. MineCode27

    MineCode27

    Joined:
    Dec 27, 2013
    Posts:
    9
    Thank you! That worked perfect.
     
    Gregoryl likes this.