Forum Discussion
davidmcclure
13 years agoHonored Guest
Help! Trouble Parenting Hydra Objects To OVRPlayerController
I am trying to set up a scene where the player has 1:1 control over a pair of handheld objects using the Razer Hydra.
Currently I can achieve the following:
Set up a scene with the OVRPlayerController in
Get objects to move with the Hydra
However, when it comes to getting the two to work together I am stuck.
I was originally using the raw position from the Hydra, but this moved the objects at a huge distance. I then started using a set made to help people get started with the Hydra in Unity that I downloaded from ( http://sixense.com/forum/vbulletin/showthread.php?4046-Getting-Started-with-the-Hyrda-in-Unity-%28package-and-instructions-included!%29 ). My current problem is that the manipulatable objects stay at one position in the world, instead of moving around with the OVRPlayerController. I have tried parenting all manner of objects to the OVRPlayerController, but this isn't solving the problem.
Please help!
Currently I can achieve the following:
Set up a scene with the OVRPlayerController in
Get objects to move with the Hydra
However, when it comes to getting the two to work together I am stuck.
I was originally using the raw position from the Hydra, but this moved the objects at a huge distance. I then started using a set made to help people get started with the Hydra in Unity that I downloaded from ( http://sixense.com/forum/vbulletin/showthread.php?4046-Getting-Started-with-the-Hyrda-in-Unity-%28package-and-instructions-included!%29 ). My current problem is that the manipulatable objects stay at one position in the world, instead of moving around with the OVRPlayerController. I have tried parenting all manner of objects to the OVRPlayerController, but this isn't solving the problem.
Please help!
6 Replies
Replies have been turned off for this discussion
- longshotHonored GuestIt's hard to know what the problem is without seeing your code.
Off the top of my head, are you setting transform.localPosition? - KrisperExplorerI haven't done this myself with the OVRPlayer, just a standard character controller at the moment.
Did you try making the Hydra objects children of the OVRPlayer? I am using the hand models that come with the sixense Unity demo, just dragged them onto the Character and they move around with the character as you would expect. - davidmcclureHonored Guestlongshot, Krisper, thanks for the responses.
Krisper:
I had tried parenting the Hydra hands to the OVRPlayerController but every time I played the scene in Unity it crashed. I have since found out that this is just a problem I am having when I launch a scene using the Hydra more than once - I will contact Sixense about this. I made a new scene by saving out the Hydra hands and I can confirm that parenting them to the OVRPlayerController worked fine.
longshot:
I hadn't been using transform.localPosition, so I gave this a shot. Unfortunately, I can't seem to get it working properly and I still have to convert the output from the Hydra to a smaller 'arms length' scale. I think I should be able to test what I wanted to test fine using the hands, but I would like to get to the bottom of this. I've included my code below; I'm afraid I'm not a coder, so it's not very good at all.public class SixEnseInputGet : MonoBehaviour {
public GameObject LeftHandObject;
public GameObject RightHandObject;
public GameObject PlayerObject;
// Use this for initialization
void Start () {
LeftHandObject = GameObject.Find("Torch");
RightHandObject = GameObject.Find("Gun");
PlayerObject = GameObject.Find ("OVRPlayerController");
}
// Update is called once per frame
void Update () {
LeftHandObject.transform.localPosition = SixenseInput.Controllers[0].Position;
RightHandObject.transform.localPosition = SixenseInput.Controllers[1].Position;
LeftHandObject.transform.rotation = SixenseInput.Controllers[0].Rotation;
RightHandObject.transform.rotation = SixenseInput.Controllers[1].Rotation;
}
} - KrisperExplorerNot sure how much I can help. I used the SixenseInput package from the Unity Store. It has a couple of demo scenes, one to show the animated hands in action, the other showing the input values on the screen. I studied them to see how they work.
I am using the hands in my project so from that package the scripts I used were:-
SixensePlugin.cs
SixenseInput.cs
SixenseObjectController.cs
SixenseHandController.cs
If you are not using the hands you won't need the last script as it is derived from SixenseObjectController.cs and only handles the hand animations.
I have the SixenseInput.cs script on an empty object in the scene, then drop a SixenseObjectController on the objects you want to control. This has 2 public settings to make, which Hand the object will be controlled by, and the Sensitivity.
Then start the game and click the start buttons on the controllers and the objects should move. Hope that helps. - Mrob76oHonored GuestI have it working perfectly in my game. what control setup are you trying to achieve?
I have mine setup so that the left joystick turns and the right does forward backwards and strafe (until I get my omni). I have all the buttons mapped and have the hands from the demo attached to my player controller ( i will replace them with my own models once I have made them) I don't actually have my rift yet so i'm just working without it for now getting everything else working. I have to add the hyrax joystick controls into the OVRplayercontroller script and I Use uScript for unity and made my own button event nodes for this.
Everything you want to parent to the player controller needs to be parented to the ForwardDirection object. except if you are making a hud which will need to be parented to the Right camera
another tip if you are using the hands and want to attach objects to them. you will notice that the left hand is scaled negatively in the x axis which works but screws up the axis when rotating child objects attached to it. Just scale it the same on the other axis and rotate it back into position. - insomnia686Honored GuestHi,
It is an old post but I wanted to bring my contribution for the future people who needs it.
This is how I use the Hydra joysticks to manipulate the Oculus Rift DK1 Camera on Unity 5.5.1.
I have drag and drop the prefab SixenseInput in my scene.
I did not update the driver of the Hydra, just plug&play (it makes crap):smile:
I have modified the script OVRPlayerController in UpdateMovement():
andfloat leftAxisX = OVRGamepadController.GPC_GetAxis(OVRGamepadController.Axis.LeftXAxis);
float leftAxisY = OVRGamepadController.GPC_GetAxis(OVRGamepadController.Axis.LeftYAxis);
//Take Hydra Left Joystick value
if (leftAxisX == 0.0)
leftAxisX = SixenseInput.Controllers[0].JoystickX;
if (leftAxisY == 0.0)
leftAxisY = SixenseInput.Controllers[0].JoystickY;float rightAxisX = OVRGamepadController.GPC_GetAxis(OVRGamepadController.Axis.RightXAxis);
//Take Hydra Right Joystick X value
if (rightAxisX == 0.0)
rightAxisX = SixenseInput.Controllers[1].JoystickX;
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
- 2 years ago
- 4 years ago