Skip to main content
Participant
June 9, 2013

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.
    This topic has been closed for replies.

    31 replies

    Inspiring
    June 11, 2013
    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?
    Titans of Space PLUS for Quest is now available on DrashVR.com
    Inspiring
    June 11, 2013
    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.
    AMD Ryzen 7 1800X | MSI X370 Titanium | G.Skill 16GB DDR4 3200 | EVGA SuperNOVA 1000 | Corsair Hydro H110i Gigabyte RX Vega 64 x2 | Samsung 960 Evo M.2 500GB | Seagate FireCuda SSHD 2TB | Phanteks ENTHOO EVOLV
    Participant
    June 11, 2013
    Thank-you for the responses guys, that's exactly what I wanted...now at least I know what direction to look in. Much appreciated.
    Up and Coming
    June 21, 2013
    "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
    Inspiring
    June 22, 2013
    It's in OVRPlayerController under motor (you need to click the down arrow).
    AMD Ryzen 7 1800X | MSI X370 Titanium | G.Skill 16GB DDR4 3200 | EVGA SuperNOVA 1000 | Corsair Hydro H110i Gigabyte RX Vega 64 x2 | Samsung 960 Evo M.2 500GB | Seagate FireCuda SSHD 2TB | Phanteks ENTHOO EVOLV
    Up and Coming
    June 24, 2013
    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
    Inspiring
    June 25, 2013
    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.
    AMD Ryzen 7 1800X | MSI X370 Titanium | G.Skill 16GB DDR4 3200 | EVGA SuperNOVA 1000 | Corsair Hydro H110i Gigabyte RX Vega 64 x2 | Samsung 960 Evo M.2 500GB | Seagate FireCuda SSHD 2TB | Phanteks ENTHOO EVOLV
    Up and Coming
    June 25, 2013
    OK, and thanks for having a look at this.
    Inspiring
    June 25, 2013
    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.
    Peter Giokaris Senior Software Engineer
    Up and Coming
    June 26, 2013
    Yes 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