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

VR. Move player in direction in which the player is looking

Discussion in 'AR/VR (XR) Discussion' started by izeko2004, Feb 11, 2019.

  1. izeko2004

    izeko2004

    Joined:
    Dec 28, 2014
    Posts:
    74
    I have enabled VR (cardboard) in player settings. With this, I can look around within my scene. I have also modified the firstpersoncontroller.cs so that I can use a Bluetooth controller to move forward and backwards.

    private void GetInput(out float speed)
    {
    // Read input
    //float horizontal = CrossPlatformInputManager.GetAxis("Horizontal");
    //float vertical = CrossPlatformInputManager.GetAxis("Vertical");
    float vertical = Input.GetAxis("Horizontal") * Time.deltaTime * 10.0f;

    This works well, but not if a look left or right. I want to move in the direction I am looking. How do I achieve this?

    Thanks.