Search Unity

Forcing Cinemachine cam to jump to a new position

Discussion in 'Cinemachine' started by ChickenVegetable, Jun 24, 2022.

  1. ChickenVegetable

    ChickenVegetable

    Joined:
    May 3, 2020
    Posts:
    87
    Hi,

    For an infinite runner style engine, I periodically "teleport" the whole game world back to zero so the coordinate values don't get too big.

    Can I force a cinemachine set to follow a target to jump position like this, while retaining any inertia etc? Just setting the position with another script on the virtualCamera doesn't work.

    Thanks!
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,728
    Yes, when the player teleports, call vcam.OnTargetObjectWarped() with the player's displacement. Alternatively, you can call CinemachineCore.OnTargetObjectWarped(), which will seamlessly teleport all vcams targeting the object in question.
     
  3. ChickenVegetable

    ChickenVegetable

    Joined:
    May 3, 2020
    Posts:
    87
    Perfect! Thanks