Forum Discussion
thiagoeo
12 years agoHonored Guest
OVRPlayerController with a generic joystick
Hello, when I create a first person controller with an OVRCameraController attached to it, i can move it with a generic joystick, with some bugs. But when I create an OVRPlayerController, it just doesn't move through the joystick. It moves just fine with the arrows and wasd. Does anyone know why?
9 Replies
Replies have been turned off for this discussion
- ima747ExplorerI'm having a similar problem. Using an xbox 360 wireless game pad, the inputs are detected fine, and used to work fine with the unity prefabs and the tuscany demo. I haven't tried it since a few revisions of the lib ago. But now it doesn't do anything. The inputs work fine when I address them myself... is the OVR gamepad controller broken in 0.2.5c? I suspect this is the same issues so posting in this thread.
- thiagoeoHonored GuestSolved it, all I needed to do was add this:
// Joystick
if (Input.GetAxis("Vertical") > 0) moveForward = true;
if (Input.GetAxis("Horizontal") < 0) moveLeft = true;
if (Input.GetAxis("Vertical") < 0) moveBack = true;
if (Input.GetAxis("Horizontal") > 0) moveRight = true;
in the OVRPlayerController.cs script, that's attached to the OVRPlayerController prefab, below this (line 218):// WASD
if (Input.GetKey(KeyCode.W)) moveForward = true;
if (Input.GetKey(KeyCode.A)) moveLeft = true;
if (Input.GetKey(KeyCode.S)) moveBack = true;
if (Input.GetKey(KeyCode.D)) moveRight = true;
// Arrow keys
if (Input.GetKey(KeyCode.UpArrow)) moveForward = true;
if (Input.GetKey(KeyCode.LeftArrow)) moveLeft = true;
if (Input.GetKey(KeyCode.DownArrow)) moveBack = true;
if (Input.GetKey(KeyCode.RightArrow)) moveRight = true;
After that it started moving inverted, but then i just changed the <> signs in the code to fix it. Also it started moving by itself, always returning 1 in the Input.GetAxis, i solved that by changing the Joy Num from "Get motion from all joysticks" to the specific joystick I wanted to use in the input settings->vertical/horizontal. - Dboutros1979Honored GuestI tried out your solution, but could not get it to run correctly.
My Xbox 360 wireless was sadly not recognised. I pasted in your solution into line 218, with the first paragraph underneath it. Sadly it would still not run.
Was there something I was meant to delete?
I have it laid up like this:// * * * * * * * * * * *
// Keyboard input
// Move
// WASD
if (Input.GetKey(KeyCode.W)) moveForward = true;
if (Input.GetKey(KeyCode.A)) moveLeft = true;
if (Input.GetKey(KeyCode.S)) moveBack = true;
if (Input.GetKey(KeyCode.D)) moveRight = true;
// Arrow keys
if (Input.GetKey(KeyCode.UpArrow)) moveForward = true;
if (Input.GetKey(KeyCode.LeftArrow)) moveLeft = true;
if (Input.GetKey(KeyCode.DownArrow)) moveBack = true;
if (Input.GetKey(KeyCode.RightArrow)) moveRight = true;
// Joystick
if (Input.GetAxis("Vertical") > 0) moveForward = true;
if (Input.GetAxis("Horizontal") < 0) moveLeft = true;
if (Input.GetAxis("Vertical") < 0) moveBack = true;
if (Input.GetAxis("Horizontal") > 0) moveRight = true;
if ( (moveForward && moveLeft) || (moveForward && moveRight) ||
(moveBack && moveLeft) || (moveBack && moveRight) )
MoveScale = 0.70710678f;
// No positional movement if we are in the air
if (!Controller.isGrounded)
MoveScale = 0.0f;
MoveScale *= DeltaTime; - virtualswedenExplorerGreat script.
I can now use my GamePad
However when using the script the player drifts to the left all the time, no matter what I do. - moltonExplorercool, I've been meaning to look into directinput support, and it looks very straight forward.
"virtualsweden" wrote:
... when using the script the player drifts to the left all the time, no matter what I do.
you probably want to setup some kind of deadzone, which I guess could be done by changing those 0 values to higher/lower ones on the getaxis lines. - bdeschryverExplorerHey guys,
I wanted to integrate joystick control but using joystick up/down to move forxward/backward and joystick left/right to replace the mouse look (horizontal).
Any idea how to do that ? SHould it be in the OvrPlayerController script or in the input settings ?
Thanks ! - moltonExplorerIt;s all in that script, yes. Just look at the keyboard input or xinput gamepad input and / or the mouse rotational input and adapt it to a gamepad.
- bdeschryverExplorerShould this code not be in the OVRGamePadController instead ? I think this bit of code is to interface with gamepad and joysticks no?
- moltonExplorerI don't know, the more I think about it, the more I like people all using the same joystick and not having to make people mess with configurations and having a standard layout so you can say "press A to start", etc. It's probably no fun trying to configure a gamepad with the Rift on. I'll probably add gamepad support but make it really general and try to avoid configurations if possible. I can deffinetly understand why Oculus might want to promote xinput, I never really liked the idea of using it and have a bunch of non-xinput controllers, but I'm glad I got an xbox controller and added support for that in my Rift experience.
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
- 8 months ago
- 4 years ago