Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question Centring 360 video to camera in worldview

Discussion in 'VR' started by lz7cjc, May 6, 2022.

  1. lz7cjc

    lz7cjc

    Joined:
    Sep 10, 2019
    Posts:
    522
    Hi
    I am streaming 360 films from Youtube into my Google Cardboard app and the camera is always pointing at a different place.
    The process is the user TPs to a film space within the app and then I do this:
    Code (CSharp):
    1.  
    2.  private Rigidbody Player;
    3.  public GameObject targetfilm;
    4.     public GameObject mainCamera;
    5.     Vector3 m_EulerAngleVelocity;
    6. ...
    7. ...
    8. Player.transform.position = targetfilm.transform.position;
    9.             Player.transform.SetParent(targetfilm.transform);
    10.            // Player.transform.rotation = Quaternion.Euler(0, 0, 0);
    11.             m_EulerAngleVelocity = new Vector3(0, 0, 0);
    12.             Quaternion deltaRotation = Quaternion.Euler(m_EulerAngleVelocity * Time.fixedDeltaTime);
    13.  
    14.             Player.MoveRotation(Player.rotation * deltaRotation);
    15.  
    16.             mainCamera.transform.rotation = Quaternion.Euler(0, 0, 0);
    where the targetfilm is static, the maincamera sits inside the player object and I move the player around the scene.

    How do I ensure that the camera is always pointing in the same direction as the code above doesn't seem to work

    thanks for your help
     
  2. arfish

    arfish

    Joined:
    Jan 28, 2017
    Posts:
    777
    Hello,

    How about rotate the targetfilm to where the player is looking, instead of rotating the player to 0,0,0?

    Like this, for example:
    targetfilm.eulerAngles = Vector3.up * mainCamera.transform.eulerAngles.y;
     
    lz7cjc likes this.
  3. lz7cjc

    lz7cjc

    Joined:
    Sep 10, 2019
    Posts:
    522
    thanks @arfish but I don't get the property eulerAngles on the targefilm object:
    targetfilm.eulerAngles = ...


    Does this replace all the other rotations I am doing if I get it to work?
    thanks
     
  4. lz7cjc

    lz7cjc

    Joined:
    Sep 10, 2019
    Posts:
    522
    @arfish if you have any ideas I would be very grateful. Thanks
     
  5. arfish

    arfish

    Joined:
    Jan 28, 2017
    Posts:
    777

    Not sure what's your problem. The code make absolutely no sense.
    I saw you have made the target film static, so rotating its transform might not make so much visible difference.

    You are moving around the player in the scene, right?
    Perhaps it's just the camera rig that's not aligned to the player then on start.
    How about recenter the rig so the player is looking in the player forward direction?
    All VR-rigs have methods for this, as far as I know.
    Just recenter to set the camera localEulerAngles to 0 which should make it look in the player forward direction.
     
    Last edited: May 14, 2022
  6. lz7cjc

    lz7cjc

    Joined:
    Sep 10, 2019
    Posts:
    522
    thanks but I don't use a VR rig as last time I tried I was unable to control the scene in the editor run game mode which made life very difficult. In addition I could get a reticle pointer that just worked with gaze and pick.

    Will investigate whether these have changed but currently use a normal camera with elements of GVReditor (it is also why I am still on 2019.4.x
     
  7. arfish

    arfish

    Joined:
    Jan 28, 2017
    Posts:
    777
  8. lz7cjc

    lz7cjc

    Joined:
    Sep 10, 2019
    Posts:
    522
    will do - thanks for your help