Moving Oculus controller back and forth(along the z axis) — Oculus
Welcome to the Oculus Developer Forums!

Your participation on the forum is subject to the Oculus Code of Conduct.

In general, please be respectful and kind. If you violate the Oculus Code of Conduct, your access to the developer forums may be revoked at the discretion of Oculus staff.

Moving Oculus controller back and forth(along the z axis)

AliHammzaAliHammza Posts: 10
NerveGear
Hey,
I have written a script to pick an object with a rigidbody component by the ray casted from the controller and move it around. 
I parent the object to the controller to move it in the scene then. However, I can not move neither the controller nor the object in the forward or backward direction. I can move it up and down or in a circle but I also want to move it along the z axis. 

If anyone could point me in a right direction or help me with this, I would greatly appreciate it!

Thanks in advance.

Tagged:

Comments

  • VR-Lab-nlVR-Lab-nl Posts: 29
    Brain Burst
    In Unreal we have access to "RawSensorData" from which you can read acceleration data, I'm sure Unity does also support this.
  • AliHammzaAliHammza Posts: 10
    NerveGear
    Hey, could you elaborate a bit please, since I am very new to this.
  • VR-Lab-nlVR-Lab-nl Posts: 29
    Brain Burst
    I am assuming, looking at the tags off your post, you are developing for the Go.
    The Go controller does not support '6 degrees of freedom' (6 dof) but is limited to 3 degrees and therefor does not support up/down, left/right, forward/back.

    I have tried the the 'GetRawSensorData' method (from the Oculus ) reads acceleration data from the device (the controller in this case)  which you can use to (sortof) determine the direction in which it was moved.
    In Unreal this is the signature of the method:
    void GetRawSensorData(
        FVector & AngularAcceleration,
        FVector & LinearAcceleration,
        FVector & AngularVelocity,
        FVector & LinearVelocity,
        float & TimeInSeconds
    )
    Hope this helps you to find the method in the Unity OVR plugin.
  • VR-Lab-nlVR-Lab-nl Posts: 29
    Brain Burst
    Just spoke to a Unity guy, he gave me these directions:
    OVRPlugin.GetNodeAcceleration(OVRPlugin.Node.HandRight, OVRPlugin.Step.Render).FromFlippedZVector3f();
    And a snippet from within the OVRPlugin:
    if (version >= OVRP_1_12_0.version)
                return OVRP_1_12_0.ovrp_GetNodePoseState(stepId, nodeId).Acceleration;

            if (version >= OVRP_1_8_0.version && stepId == Step.Physics)
                return OVRP_1_8_0.ovrp_GetNodeAcceleration2(0, nodeId).Position;

            return OVRP_0_1_3.ovrp_GetNodeAcceleration(nodeId).Position;




  • AliHammzaAliHammza Posts: 10
    NerveGear
    Ohh ok. Thank a lot.  The Go controller does not support '6 degrees of freedom' , is there any other way to move object forward/back after parenting it to the controller by pressing the trigger button.
  • VR-Lab-nlVR-Lab-nl Posts: 29
    Brain Burst
    Guess you could do that by pressing the trigger (or measuring the axis value of the trigger?)
    I have a setup in which I use the trackpad/thumbpad axis value to move the picked up object forward and backward.
  • AliHammzaAliHammza Posts: 10
    NerveGear
    i did that by pressing the trigger, but since the go controller does not move back and forth, therefore I can not move the object in that direction either. It only moves up or down or right or left on a circle.

  • AliHammzaAliHammza Posts: 10
    NerveGear
    VR-Lab-nl said:
    Guess you could do that by pressing the trigger (or measuring the axis value of the trigger?)
    I have a setup in which I use the trackpad/thumbpad axis value to move the picked up object forward and backward.
    Hey, could you please share that setup/script that you used for the movement of the objects along the z axis?
  • VR-Lab-nlVR-Lab-nl Posts: 29
    Brain Burst
    AliHammza said:
    i did that by pressing the trigger, but since the go controller does not move back and forth, therefore I can not move the object in that direction either. It only moves up or down or right or left on a circle.

    That circular motion is the 3dof in action: you are seeing the registered rotation of the controller.

    As for the script, this part was done in Unreal's blueprints:

    'GetUpDown' gives an axis value from -1 to 1 of the position of your thumb on the pad. 'MaxMoveAmount' is how far the object should move forward (or backward) 'StickLocationZero' is the original position of the object.
  • AliHammzaAliHammza Posts: 10
    NerveGear
    This looks very different. I'll try to write a C# script for unity based on this but i'm not sure if it work lol.
    Thanks a lot tho
  • VR-Lab-nlVR-Lab-nl Posts: 29
    Brain Burst
    See if that works out. I might refactor this blueprint into proper C++ code somewhere in the next few weeks.
  • AliHammzaAliHammza Posts: 10
    NerveGear
    Yeah, I'll try that. Also, will e great if you could let me know, if you refactor it into a c++ or c# code.
Sign In or Register to comment.