cancel
Showing results for 
Search instead for 
Did you mean: 

Help needed to add jump function to OVR Player Controller?

peteclarkelondon
Honored Guest
Hi All,

I'm hoping some kind person may be able to help me or point me in the right direction. I started learning Unity a few weeks back before I got the Rift. I decided to try and do a 'moon based' demo as I thought the change in gravity would be fun and it's a good environment for me to experiment with while I learn.

I had it working beautifully before the Rift arrived, able to walk and jump around the lunar landscaper. Since getting the Rift I removed the my old control type (from the 'standard assets' that ship with Unity) and added the Oculus Controller. This works fine apart from I now have no jump function and I've tried a variety of things to get it back with no success. As my lunar environment requires jumping and low gravity, it's proving a bit of a nightmare.

I am a newbie, and I'm sure that the answer is pretty simple so if someone could at least point me in the right direction I would be eternally grateful.

Thanks in advance.
31 REPLIES 31

drash
Heroic Explorer
To be honest I don't have a lot of experience working with the OVRPlayerController, but I believe it does support jumping (with a configurable jump force applied when you jump). The key point being, when using Oculus' Unity integration, you generally have to decide between using an OVRPlayerController or an OVRCameraController. OVRPlayerController is basically the OVRCameraController PLUS FPS-style control, kinda like the FirstPersonController standard asset from Unity. The player controller isn't always a good fit depending on what you're trying to do but it's good for quick and dirty stuff.

Does that help?

cybereality
Grand Champion
In OVRPlayerController.cs in the function UpdateMovement(), you can add the following:

if (Input.GetKey(KeyCode.F)) Jump();


This will let you press the F key to jump. You may also want to edit the properties in Unity to get a better feel to the jump. In the OVRPlayerController script properties there is the Motor->Jump Force. And Physics->Gravity Modifier.

Hope that helps.

peteclarkelondon
Honored Guest
Thank-you for the responses guys, that's exactly what I wanted...now at least I know what direction to look in. Much appreciated.

Boff
Honored Guest
"cybereality" wrote:
In OVRPlayerController.cs in the function UpdateMovement(), you can add the following:

if (Input.GetKey(KeyCode.F)) Jump();


This will let you press the F key to jump. You may also want to edit the properties in Unity to get a better feel to the jump. In the OVRPlayerController script properties there is the Motor->Jump Force. And Physics->Gravity Modifier.

Hope that helps.


Hi Cyber, thanks to your advice I've added jumping to the Tuscany demo, but I can't see 'Jump Force' in the Inspector for OVRPlayerController (under the 'OVRPlayer Controller (Script)' section). 'Gravity Modifier' is there, amongst others.

I've checked OVRPlayerController.cs and 'JumpForce' is a Public Float so shouldn't it be exposed in the Inspector?

Cheers
Boff

cybereality
Grand Champion
It's in OVRPlayerController under motor (you need to click the down arrow).

Boff
Honored Guest
I've tried removing and re-adding OVRPlayerController.cs to the OVRPlayerController GameObject, and also removing the OVRPlayerController GameObject and adding it back in to the Tuscany demo, but it makes no difference.

I've attached a screenshot for convenience:


See what I mean?

Cheers
Boff

cybereality
Grand Champion
Well I was looking at an old build. With the most recent SDK I am seeing the same as you are seeing. This is strange to me since, "JumpForce" is public. I even tried adding new public variables and they don't show up either. Give me a second to get to the bottom of this.

Boff
Honored Guest
OK, and thanks for having a look at this.

petergiokaris
Protege
All,

There is a special editor script called OVRPlayerControllerEditor.cs in the Editor folder for custom Inspector layouts. You must edit this as well in order to view public variables. Please have a look at this file to see how to add Jump into PlayerController.