Skip to main content
Up and Coming
September 15, 2018

Custom Float Controller

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


This topic has been closed for replies.

5 replies

L4Z3RC47Author
Up and Coming
September 18, 2018
@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.
L4Z3RC47Author
Up and Coming
September 19, 2018
@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);


L4Z3RC47Author
Up and Coming
September 25, 2018
@imperativity
Thanks. I'll be digging into it as well this week so I'll post an update if I figure it out
kojack
Honored Contributor
September 26, 2018

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.




Author: Oculus Monitor , Auto Oculus Touch , Forum Dark Mode , Phantom Touch Remover , X-Plane Fixer Hardware: Threadripper 1950x, MSI Gaming Trio 2080TI, Asrock X399 Taich Headsets: Wrap 1200VR, DK1, DK2, CV1, Rift-S, GearVR, Go, Quest, Quest 2, Reverb G2, Quest 3
L4Z3RC47Author
Up and Coming
November 8, 2018
Thank you! I had a feeling like there was something small I was missing there :s