Search Unity

Question How can I save all the cinemachine free look camera properties values ?

Discussion in 'Cinemachine' started by SharonL75, Oct 10, 2020.

  1. SharonL75

    SharonL75

    Joined:
    Aug 13, 2020
    Posts:
    91
    Something like this idea logic :

    Code (csharp):
    1.  
    2. using System;
    3. using System.Collections;
    4. using System.Collections.Generic;
    5. using UnityEngine;
    6. using Cinemachine;
    7.  
    8. [Serializable]
    9. public class FreeLookCameraSaver
    10. {
    11.     CinemachineFreeLook.TransitionParams tp;
    12.     CinemachineFreeLook.Orbit or;
    13.    
    14.     public void tpp()
    15.     {
    16.        
    17.     }
    18. }
    19.  
    Like I did for regular object transform example :

    Code (csharp):
    1.  
    2. using System;
    3. using System.Collections;
    4. using System.Collections.Generic;
    5. using UnityEngine;
    6.  
    7. [Serializable]
    8. public class TransformSaver
    9. {
    10.     public Vector3 position;
    11.     public Vector3 scaling;
    12.     public Quaternion rotation;
    13. }
    14.  
    And then in my SaveObject class I can call and use the TransformSaver :

    Code (csharp):
    1.  
    2. using System;
    3. using System.Collections.Generic;
    4. using UnityEngine;
    5.  
    6. [Serializable]
    7. public class SaveObject
    8. {
    9.     public List<KeyToValue> componentsState;
    10.     public string gameObjectUniqueID;
    11.  
    12.     public TransformSaver transformSaver;
    13. }
    14.  
    Now I want to do something like that for the free look camera properties.
     
  2. SharonL75

    SharonL75

    Joined:
    Aug 13, 2020
    Posts:
    91
    The problem is that in the game I have two free look cameras one for close range to the player face for playing clips like scenes the other camera is a bit far from the player that camera is to game play when the player is moving around.

    The problem is when I'm loading the game it's doing automatic transition from the current camera to the close look camera. And it looks strange because when I'm loading the game the player can move around so if the player is looking up the sky when the saved game is loading it will make transition from the player looking at the sky to the camera.

    I'm bit confused here.

    This is the close range camera :

    upload_2020-10-10_7-57-3.png

    And this is the far camera. When the start new game first time it's making automatic transition from the close range camera to the far camera and this is fine. But when I'm loading the game after that at another point in the game I don't want it to make a transition between camera just to start with the far camera already.

    upload_2020-10-10_7-59-38.png
     
  3. gaborkb

    gaborkb

    Unity Technologies

    Joined:
    Nov 7, 2019
    Posts:
    856
    How do you control which freelook vcam is live?

    You could save which camera was active, and then on load you make that vcam the live one. Either by giving it the highest priority or disabling all other vcams, and enabling the one saved.
     
    SharonL75 likes this.