Welcome to the Oculus Developer Forums!

Your participation on the forum is subject to the Oculus Code of Conduct.

In general, please be respectful and kind. If you violate the Oculus Code of Conduct, your access to the developer forums may be revoked at the discretion of Oculus staff.

Custom Float Controller

L4Z3RC47L4Z3RC47 Posts: 17 Oculus Start Member
I'm currently working on a custom controller implementation based on the existing OVRPlayerController. In this setup the player is situated in a floating space. Basically what we need to do is eliminate gravity, and add controller for the secondaryAxis.y to control moving the player straight up and down. By modifying the OVRPlayerController script saved as OVRCustomPlayerController we're really close but are getting some results that are a little perplexing.

Current issues are:
1: The player only moves up and down if the primaryAxis is triggered and thus also moving the player left right forwards or backwards
2: Up and down on the secondary axis seems to be changing the forward/backwards vector rather than propelling the player itself, so if you move backwards by pulling back on the primaryAxis.y while setting the vector to up with the secondaryAxis.y you move backwards and down rather than backwards and up.

Does anyone out there have any input on how we could achieve propelling the player in the y direction independently and reliably?

Code attached below


Comments

  • L4Z3RC47L4Z3RC47 Posts: 17 Oculus Start Member
    @imperativity

    Hi, thanks for the input. Did you look at the code I referenced? Not sure what you mean by pointing me to OVRInput. This is the class that is used for getting controller input yes but that wasn't really what I was asking about. If you take the attached custom player controller in the link of my OP and apply it as a player controller you'll see what I'm trying to get at. Other than the up/down weirdness the way the controls are setup are very intentional.
  • L4Z3RC47L4Z3RC47 Posts: 17 Oculus Start Member
    @imperativity

    If you have the time that would be great, thanks!

    As a quick primer basically what we've got going on is adding a Y component to section handling the movement updates and polling
    OVRInput.Get(OVRInput.Axis2D.SecondaryThumbstick.y)

    I suspect there is something to what I'm doing here that could explain whats going on : 
    1. if (secondaryAxis.y < 0.0f)
    2.                 MoveThrottle += ort * (Mathf.Abs(primaryAxis.y) * transform.lossyScale.y * moveInfluence *
    3.                                        BackAndSideDampen * Vector3.down);
    4.  
    5.             if (secondaryAxis.y > 0.0f)
    6.                 MoveThrottle += ort * (primaryAxis.y * transform.lossyScale.y * moveInfluence * BackAndSideDampen *
    7.                                        Vector3.up);


  • L4Z3RC47L4Z3RC47 Posts: 17 Oculus Start Member
    @imperativity
    Thanks. I'll be digging into it as well this week so I'll post an update if I figure it out
  • kojackkojack Posts: 4,902 Volunteer Moderator
    L4Z3RC47 said:

    1: The player only moves up and down if the primaryAxis is triggered and thus also moving the player left right forwards or backwards

    In the code snippet you posted, the amount of up/down movement is being scaled by the primaryAxis.y (forward/back) value. I'm guessing this should be the secondaryAxis.y instead.

    L4Z3RC47 said:

    2: Up and down on the secondary axis seems to be changing the forward/backwards vector rather than propelling the player itself, so if you move backwards by pulling back on the primaryAxis.y while setting the vector to up with the secondaryAxis.y you move backwards and down rather than backwards and up.

    Also in the snippet, the top check (for down) uses MathF.Abs to force the primaryAxis.y to be positive. But the check for up is missing the Abs call, so if you are moving backwards then primaryAxis.y is negative, that is being multiplied by the up vector to make it a down vector.

    Try this:
    1. if (secondaryAxis.y < 0.0f)
    2.                 MoveThrottle += ort * (Mathf.Abs(secondaryAxis.y) * transform.lossyScale.y * moveInfluence *
    3.                                        BackAndSideDampen * Vector3.down);
    4.  
    5.             if (secondaryAxis.y > 0.0f)
    6.                 MoveThrottle += ort * (Mathf.Abs(secondaryAxis.y) * transform.lossyScale.y * moveInfluence * BackAndSideDampen *
    7.                                        Vector3.up);

    What I would probably do is cut that down to just one check like:
    MoveThrottle += ort * secondaryAxis.y * transform.lossyScale.y * moveInfluence * BackAndSideDampen * Vector3.up;
    If secondaryAxis.y is negative, then it reverses the up vector naturally.




  • L4Z3RC47L4Z3RC47 Posts: 17 Oculus Start Member
    Thank you! I had a feeling like there was something small I was missing there :s
Sign In or Register to comment.