Centring 360 video to camera in worldview

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:

 private Rigidbody Player;
 public GameObject targetfilm;
    public GameObject mainCamera;
    Vector3 m_EulerAngleVelocity;
...
...
Player.transform.position = targetfilm.transform.position;
            Player.transform.SetParent(targetfilm.transform);
           // Player.transform.rotation = Quaternion.Euler(0, 0, 0);
            m_EulerAngleVelocity = new Vector3(0, 0, 0);
            Quaternion deltaRotation = Quaternion.Euler(m_EulerAngleVelocity * Time.fixedDeltaTime);

            Player.MoveRotation(Player.rotation * deltaRotation);

            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

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;

1 Like

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

@arfish if you have any ideas I would be very grateful. Thanks

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.

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

Try this:

1 Like

will do - thanks for your help