3
\$\begingroup\$

I am working on a virtual walkthrough using Google Cardboard in Unity 5.3.5.

I have a building, and I need to move around inside the room using google cardboard. How can I do that? Is it possible to move around when we walk holding the Google Cardboard? I have done movement using arrow key. I am able to turn around the building with Google Cardboard.

\$\endgroup\$
4
\$\begingroup\$

No, the user does not walk around while using VR. That would be extremely dangerous as your are effectively blind to your real-world surroundings. You could stub your toe on your coffee table, or fall off a cliff, depending where you are.

VR relies on some sort of stationary controller. Whether it be keyboard and mouse, PlayStation controller, or Kinect sensors reading body movements, in all cases the user generally doesn't move more than a foot or so from their location while wearing the vision-impairing head unit.

Augmented reality, on the other hand, does allow the user to move around and interact with the real world in some enhanced (i.e. augmented) way. An example of an augmented reality device would be Google Glass.

\$\endgroup\$
2
\$\begingroup\$

Most games get around the problem of you hitting wall in VR by teleporting you around. This is usually done in such a way that the player can push a button to teleport where they are looking.

The easiest way to implement this would be to use the button on top of the Cardboard to trigger a touch event. This event would send a raycast and teleport you to the destination if it is valid ( e.g. not inside a wall or out of bounds )

\$\endgroup\$
1
\$\begingroup\$

Here is some code that you should apply to the camera in a .cs script. Then you will be able to move around just by looking.

using UnityEngine;
using System.Collections;

public class controller : MonoBehaviour
{
    private bool walking = false;
    private Vector3 spawnPoint;

    private void Start()
    {
        spawnPoint = transform.position;
    }

    private void Update()
    {
        if (walking)
        {
            transform.position = transform.position + Camera.main.transform.forward * .5f * Time.deltaTime;
        }

        if (transform.position.y < -10f)
        {
            transform.position = spawnPoint;
        }

        Ray ray = Camera.main.ViewportPointToRay(new Vector3(.5f, .5f, 0));
        RaycastHit hit;
        if (Physics.Raycast(ray, out hit))
        {
            if (hit.collider.name.Contains("plane"))
            {
                walking = false;
            }
            else
            {
                walking = true;
            }
        }
    }
}
\$\endgroup\$
  • \$\begingroup\$ You might consider formatting your code properly in the future so people can actually read your answer. \$\endgroup\$ – Dan Jun 6 '17 at 14:07
-3
\$\begingroup\$

ummm im not a game dev but what about making it so when they touch the thingy on the side allowing that to make the character run? not sure if you can but hey its worth a shot

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.