Forum Discussion
AndyOHart
11 years agoHonored Guest
Razer Hydra help
Hey.
I'm a beginner at Unity and all this game related stuff.
Going to be doing a Razer Hydra + Oculus Rift final year project.
Basically going to try make some sort of wizard game.
Wondering is there any good tutorials for the Hydras around?
At the moment I have the hands that Sixense provide you and I can move them etc, but moving the Hydras also moves the camera.
I want to find out how I can use the joysticks for movement and moving the camera for the moment before I implement the Oculus Rift.
Thanks for any help!
I'm a beginner at Unity and all this game related stuff.
Going to be doing a Razer Hydra + Oculus Rift final year project.
Basically going to try make some sort of wizard game.
Wondering is there any good tutorials for the Hydras around?
At the moment I have the hands that Sixense provide you and I can move them etc, but moving the Hydras also moves the camera.
I want to find out how I can use the joysticks for movement and moving the camera for the moment before I implement the Oculus Rift.
Thanks for any help!
7 Replies
- serrarensHonored GuestI've done a lot of development with Rift and Hydra for Unity (check my blog below), so I think I am able to help you.
To give you a starting point (parts of the code borrowed from the standard input controller script):
SixenseInput.Controller controllerL = SixenseInput.GetController (SixenseHands.LEFT); // get left controller
if (controllerL != null && controllerL.Enabled )
{
horizontal = controllerL.JoystickX;
vertical = controllerL.JoystickY;
// Get the input vector from analog stick
directionVector = new Vector3(horizontal, 0, vertical);
if (directionVector != Vector3.zero)
{
// Get the length of the directon vector and then normalize it
// Dividing by the length is cheaper than normalizing when we already have the length anyway
float directionLength = directionVector.magnitude;
directionVector = directionVector / directionLength;
// Make sure the length is no bigger than 1
directionLength = Mathf.Min(1.0f, directionLength);
// Make the input vector more sensitive towards the extremes and less sensitive in the middle
// This makes it easier to control slow speeds when using analog sticks
directionLength = directionLength * directionLength;
// Multiply the normalized direction vector by the modified length
directionVector = directionVector * directionLength;
}
// Apply the direction to the CharacterMotor
characterMotor.inputMoveDirection = characterTransform.rotation * directionVector;
} - AndyOHartHonored GuestThanks for the indepth reply.
So with the code you provided, If I created a cube and wanted to have that act as the Hydra, would I attach the cubeto the Player Controller and add the code onto the cube or what? - serrarensHonored GuestHmm, I may have misunderstood your question... You were referring to the joysticks in your question, so I thought you wanted to use the analog sticks on top of the Hydra. The code above implements that.
But moving a cube around following the controllers is not very hard. (I needed to write this down anyway):
- download the plugin from the asset store: https://www.assetstore.unity3d.com/#/content/7953
- copy the SixenseInput prefab to your scene
- create a cube gameobject
- Attach the SixenseObjectController script to the cube game object and set the Hand paramter.
- You may want to change the scale to 0.001 for all axis
- run! - AndyOHartHonored GuestAh thank you very much, that helps me out a bunch.
So the first batch of code you posted is so you can move the character using the anologue stick on top of the hydra?
Would I add that code to one of the cube objects or to the camera?
Also, since I need to implement positional tracking, do you know of any tutorials that allows that?
EDIT
So I have a cube moving around now, and I want to make it act like a gun, but I'm not sure how I can access the buttons of the Hydra? I see in the SixenseInput script there is definitions for it all but I'm new to Unity and I'm not sure how I can access it.
Basically I want it so if(right_bumper_trigger_released) then shoot. Just not sure how I can go about it - serrarensHonored GuestUsing the Hydra for positional tracking of the Rift is straightforward. Just place the cube you have above at the location of the OVRCameraController and make the OCRCameraController a child of the cube. As the OVRCameraController's rotation is directly controlled by the Rift's trackers, only the position of the cube is propagated to the OVRCameraController et voilá: positional tracking!
(of course the cube actually should not be at the camera's position, but at the same relative position as the Hydra controller is relative to the Rift center screen. You should also take into account that the controller may be oriented sideways for example, so the camera transform needs to be rotated).
For shooting and accessing the buttons you might want to take a look at the SixenseInputTest script which is in the Sixense package you downloaded earlier.
Pascal. - AndyOHartHonored GuestWow, I didn't think the positional tracking would be that straightforward.
Thank you so much for the detailed replies, really helped me out!
I will have a look at their test script, hopefully will help me :)
I will post here if I have any other enquiries.
Thanks again man - FritoExplorer
Quick Links
- Horizon Developer Support
- Quest User Forums
- Troubleshooting Forum for problems with a game or app
- Quest Support for problems with your device
Other Meta Support
Related Content
- 12 years ago
- 12 years ago
- 12 years ago
- 12 years ago
- 9 years ago