Forum Discussion
L4Z3RC47
7 years agoProtege
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
5 Replies
Replies have been turned off for this discussion
- L4Z3RC47Protege@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. - L4Z3RC47Protege@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 :- if (secondaryAxis.y < 0.0f)
- MoveThrottle += ort * (Mathf.Abs(primaryAxis.y) * transform.lossyScale.y * moveInfluence *
- BackAndSideDampen * Vector3.down);
- if (secondaryAxis.y > 0.0f)
- MoveThrottle += ort * (primaryAxis.y * transform.lossyScale.y * moveInfluence * BackAndSideDampen *
- Vector3.up);
- L4Z3RC47Protege@imperativity
Thanks. I'll be digging into it as well this week so I'll post an update if I figure it out
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.
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.
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.Try this:- if (secondaryAxis.y < 0.0f)
- MoveThrottle += ort * (Mathf.Abs(secondaryAxis.y) * transform.lossyScale.y * moveInfluence *
- BackAndSideDampen * Vector3.down);
- if (secondaryAxis.y > 0.0f)
- MoveThrottle += ort * (Mathf.Abs(secondaryAxis.y) * transform.lossyScale.y * moveInfluence * BackAndSideDampen *
- 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.- L4Z3RC47ProtegeThank you! I had a feeling like there was something small I was missing there :s
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
- 3 months ago
- 3 months ago