Forum Discussion
peteclarkelondon
12 years agoHonored Guest
Help needed to add jump function to OVR Player Controller?
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.
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
Replies have been turned off for this discussion
- drashHeroic ExplorerTo 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? - cyberealityGrand ChampionIn 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. - peteclarkelondonHonored GuestThank-you for the responses guys, that's exactly what I wanted...now at least I know what direction to look in. Much appreciated.
- BoffExplorer
"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 - cyberealityGrand ChampionIt's in OVRPlayerController under motor (you need to click the down arrow).
- BoffExplorerI'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 - cyberealityGrand ChampionWell 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.
- BoffExplorerOK, and thanks for having a look at this.
- petergiokarisProtegeAll,
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. - BoffExplorerYes the variable is appearing in the editor now. Thanks to the both of you!
Just out of interest, was it not showing BECAUSE of the custom Inspector layout? E.g. if I deleted that editor script and forced a default Inspector layout would all the public variables show (albeit without the sliders)?
Edit: Thought it would be quicker to try it and see. And the answer is 'Yes'.
Thanks again,
Boff
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
- 6 months ago
- 1 year ago
- 3 months ago