Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Strange Camera Movement

Discussion in 'Cinemachine' started by hsklunity, Mar 24, 2023.

  1. hsklunity

    hsklunity

    Joined:
    Jun 9, 2022
    Posts:
    13
    Hi,

    I have my game divided into different parts/scenes which are loaded when needed. I am using the freelook cinemachine camera. After I hit a play button in my game menu, the player and map are loaded additionally. The freelook target and look at is then set to the player using a script.
    When the freelook is placed in a different scene than the player the camera makes strange movements as if it was placed somewhere else and now moves and rotates towards the player. Camera GameObject as well as the freelook GameObject are placed exactly at the same place where the player is (in inspector before starting the game).
    But if I place the freelook GameObject in the same scene as the Player (as a sibling not as a child), there is no such movement and the camera is immediately at the supposed position.

    Has anyone faced the same issues or knows how to resolve it other than having the freelook camera in the same scene as the player?
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,558
    In your script that assigns the player as FreeLook target, be sure also to set freeLook.PreviousStateIsValid = false. That will cancel the freeLook's memory of where it was, and so it won't lerp to the new position.
     
    hsklunity likes this.
  3. hsklunity

    hsklunity

    Joined:
    Jun 9, 2022
    Posts:
    13
    Ah yes, apparently that was the issue. Thank you very much!
     
    Gregoryl likes this.