Search Unity

Google CardBoard Demo, VR Walking Query

Discussion in 'AR/VR (XR) Discussion' started by schetty, May 28, 2015.

  1. schetty

    schetty

    Joined:
    Jul 23, 2012
    Posts:
    424
    Hi,

    I am working on the Google cardboard now, started newly i have exported the scene its working fine.
    But i want to move the camera by the user control i want to know is it possible in google card board?
    I have tried this walk control using the "transform.Translate" function in this using the "Input.Acceleration " control. But its not working properly and i odnt ge the proper controll.

    Is it possible to do this in Google Cardboard"

    If yes,Is there any other way to do this?

    Thanks.
     
  2. Tronno

    Tronno

    Joined:
    Apr 23, 2015
    Posts:
    11
    I'm not sure what you mean. Are you trying to use the phone's acceleration to determine if the user is walking? You will have a hard time doing that. The phone will constantly accelerate in all directions depending on where the user is looking.

    You will have an easier time using the Cardboard magnetic button as a toggle. Try something like this:
    Code (CSharp):
    1. void Update() {
    2.     if(Cardboard.CardboardTriggered) MoveForward();
    3. }
     
  3. schetty

    schetty

    Joined:
    Jul 23, 2012
    Posts:
    424
    i want to move my camera when user doing acceleration like moving forward, back or side direction. According to that i want to translate my camera into the scene.
     
  4. schetty

    schetty

    Joined:
    Jul 23, 2012
    Posts:
    424
    i tried this line but i am getting the following error message:
    "Assets/Scripts/CardBoardMovingCam.cs(30,31): error CS0120: An object reference is required to access non-static member `Cardboard.CardboardTriggered"
     
  5. Tronno

    Tronno

    Joined:
    Apr 23, 2015
    Posts:
    11
    My mistake. Use Cardboard.SDK.CardboardTriggered instead.
     
  6. huj1992

    huj1992

    Joined:
    Oct 25, 2015
    Posts:
    1
    Hi guys, i have just found your conversation and hoping now that you could help me.
    Currently I am working on a VR-Project with the Cardboard SDK and unity5 at my university. I am a bloody beginner and my goal is to build a VR-Application for Android that allows the User to walk in the direction he is looking when pulling the trigger.

    Until know it doesn't work at all and i don't know what to do. I have imported the CardboardSDK, than attached the autowalk.cs skript (http://bit.ly/1IRkLSW). What did I forgett? FPS-Controller? CharacterControll?

    It would be great if you guys could help me out. What should I do step by step?

    Thank you very very much. cheers Jonas
     
    wombat_wombat likes this.
  7. wombat_wombat

    wombat_wombat

    Joined:
    Oct 27, 2015
    Posts:
    2
    I also want to chime in here because I've been having a difficult time finding a solution to walking around with Google Cardboard.

    I feel like I've tried implementing ever tutorial I could get my hands on with no success. Not sure if the CharacterMotor.cs + Autowalk script solution daniel borowski's site works for others. Followed the directions to a T and nada. http://danielborowski.com/posts/create-a-virtual-reality-game-for-google-cardboard/

    This is what I'm trying to do-- when the user pulls the trigger they take a step in the direction that they're facing.

    Basically here is where I am so far:
    1. Google Demo open, I import the FPSController prefab under "Characters" and delete the child and replaced it with Cardboard Main

    2. At this point, if you hit play you can walk around based, oriented by where gaze pointer is pointing. Great.

    3. Move the FPS script to the VR Script folder to that I can call Cardboard (is there a better way to do this?)

    4. In the FPSController script, I attempt to only update the location if the trigger goes off.
    in fixed update function:
    Code (CSharp):
    1. if (Cardboard.SDK.Triggered){
    2.    m_MoveDir += Physics.gravity*m_GravityMultiplier*Time.fixedDeltaTime;
    3. }
    I'm a Unity beginner, but sort of surprised there isn't some kind of prefab for this. Would love to find a solution.
     
    Last edited: Oct 27, 2015
    Hashton likes this.
  8. wombat_wombat

    wombat_wombat

    Joined:
    Oct 27, 2015
    Posts:
    2
    Hashton likes this.
  9. Hashton

    Hashton

    Joined:
    Nov 10, 2015
    Posts:
    25
    Works brilliant thanks Wombat
     
    wombat_wombat likes this.
  10. varunb95

    varunb95

    Joined:
    Feb 25, 2016
    Posts:
    1
    I'm new to Unity, and Github....could you tell me what exactly i need to add to my project to enable walking?
     
  11. AlexKrunch

    AlexKrunch

    Joined:
    Feb 17, 2016
    Posts:
    12
    I've made a very similar script to work with the gamepad. To use it, create an empty object with a rigidBody and put the Cardboard object into.

    Code (CSharp):
    1.  
    2.                //Get the googlecarboard instance + the rigidbody of the gameobject (Put these 2 lines in the Awake())
    3.                 mHead = (CardboardHead) FindObjectOfType(typeof(CardboardHead));
    4.                 rb3D = GetComponentInParent<Rigidbody> ();
    5.  
    6.  
    7.                 //Calculate the diff between the cardboard direction and the forward of the parent object
    8.                 Vector3 forward = transform.forward;
    9.                 Vector3 vectorHead = new Vector3 (mHead.Gaze.direction.x, 0.0f, mHead.Gaze.direction.z);
    10.                 float angle = Vector3.Angle (forward, vectorHead);
    11.  
    12.                 //Is the angle negative?
    13.                 Vector3 cross = Vector3.Cross (forward, vectorHead);
    14.                 if (cross.y < 0)
    15.                     angle = -angle;
    16.  
    17.                 //Get the gamepad inputs
    18.                 float moveHorizontal = -Input.GetAxis ("Horizontal");
    19.                 float moveVertical = -Input.GetAxis ("Vertical");
    20.  
    21.                //Rotate the vector of input with the diff between this GameObject + The forward of the Carboard Object
    22.                 Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
    23.                 movement = Quaternion.Euler (0, angle, 0) * movement;
    24.  
    25.                //Move the object
    26.                 rb3D.AddForce (movement * speed * 3f);
    27.                 rb3D.velocity = Vector3.zero;
    28.                 rb3D.angularVelocity = Vector3.zero;
    To make what you want just replace the line getting the gamepad inputs (l. 17-20) by this
    Code (CSharp):
    1.  
    2. float moveHorizontal = 0;
    3. float moveVertical = 0;
    4. if (Cardboard.SDK.Triggered){
    5. moveVertical = -1;
    6. }
    7.  
     
    Last edited: Mar 3, 2016
  12. kamil0417

    kamil0417

    Joined:
    Oct 13, 2015
    Posts:
    4
    Hi!
    I'm looking for the same solution for walking (using phone sensors to walk around) but I'm struggle to manage this. If you manage to do this please let me know.
     
  13. Soquet

    Soquet

    Joined:
    Apr 2, 2016
    Posts:
    1
    I tried to get that script to work with the latest cardboard.sdk but it failed for me.
     
  14. Hashton

    Hashton

    Joined:
    Nov 10, 2015
    Posts:
    25
    I also cant get it to work with latest cardboard its a bit of a pain.
     
  15. murat-tanrikulu

    murat-tanrikulu

    Joined:
    Feb 23, 2016
    Posts:
    7
    can you someone help me walk with gaze input module? i want to walk that point whatt i create plane trigger.
     
  16. kamleshanimator

    kamleshanimator

    Joined:
    Jul 13, 2016
    Posts:
    1
    can you someone send me cardbord script?
     
  17. MichaelSolerBeatty

    MichaelSolerBeatty

    Joined:
    Jan 13, 2016
    Posts:
    54
    This could be and interesting asset for you

    https://www.assetstore.unity3d.com/en/#!/content/61864

     
  18. Selzier

    Selzier

    Joined:
    Sep 23, 2014
    Posts:
    652
    We have lots of movement tutorials on YouTube and also a movement pack here:
    https://www.assetstore.unity3d.com/en/#!/content/69041