Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question How to avoid camera position change on MARS loading?

Discussion in 'Unity MARS' started by hmkn, Dec 24, 2020.

  1. hmkn

    hmkn

    Joined:
    Nov 7, 2019
    Posts:
    23
    Hello.
    I found that when I enter play mode, MARS will override main camera position.
    Since I use camera as a field of view of the player, I would like to avoid force override the camera position.
    Is there a better way to fix it?
     
  2. amydigiov_Unity

    amydigiov_Unity

    Unity Technologies

    Joined:
    May 24, 2016
    Posts:
    16
    Hi @hmkn , the MARS Session takes control of whichever camera is tagged as "MainCamera". There are two approaches I can think to take here:
    1. Have two cameras in your scene - one which is your custom camera and another tagged as "MainCamera". If there is already a MARS Session in your scene, make sure your custom camera is not the one underneath the MARS Session's hierarchy. If there isn't a Session, add one via "Game Object -> MARS -> MARS Session". Your custom camera will render on top of the Session's camera if it has a higher "Depth" value.
    2. Alternatively, you could have a custom script that sets the MARSCamera's DisablePoseDriving property to true:
    Code (CSharp):
    1. public class CustomCamera : MonoBehaviour
    2. {
    3.     void Start()
    4.     {
    5.         MARSSession.Instance.GetComponentInChildren<MARSCamera>().DisablePoseDriving = true;
    6.     }
    7. }