No keyboard input in Unity3D game builds
Asked Answered
C

2

2

I'm using Unity3D and I'm having issues with the keyboard when I 'build' the project.

When I run the game within the Unity Editor, the input works fine. However, when I build the project and test it, I have no directional input whatsoever. The mouse works fine, the game registers keystrokes (the Esc key works), but the player won't move.

I'm using Input.GetAxisRaw("Vertical") and Input.GetAxisRaw("Horizontal")

I researched the issue on the web, but I'm still stucked. The only solution I found (in various links) mentions a problem with DirectInput and states that you should remove the key "Input" from [HKEY_CURRENT_USER\Software\Unity\Player], in the Windows registry, but that doesn't seem to work for me.

Has anybody else fought this problem? Any working solutions? Am I doing the registry trick wrong?

Cycloplegia answered 21/4, 2013 at 20:7 Comment(1)
Do you have the same problem if you take the build and run it on a different machine?Tragedienne
C
0

I've figured out what was troubling me.

Input.GetAxisRaw("Vertical") and Input.GetAxisRaw("Horizontal") were fine the whole time. Somehow, there was some code in the script that in the Editor worked just fine, but when running as standalone gave me a calculation equal to 0 (it depends on the Delta Time, so I assume that the Delta Time when running compiled is much smaller than when running in the Unity Editor) and thus the character didn't move at all.

Cycloplegia answered 30/4, 2013 at 3:8 Comment(0)
L
0

You should check out Input Manager in Edit->Project Settings-> Input. Have you tried using GetAxis instead of GetAxisRaw? I also suggest using, eg: Input.GetKey(KeyCode.A) and etc.

Lederhosen answered 21/4, 2013 at 21:1 Comment(1)
I tried both GetAxis and GetAxisRaw. I was planning of using the approach you suggest, using GetKey, if I can't solve this issue.Cycloplegia
C
0

I've figured out what was troubling me.

Input.GetAxisRaw("Vertical") and Input.GetAxisRaw("Horizontal") were fine the whole time. Somehow, there was some code in the script that in the Editor worked just fine, but when running as standalone gave me a calculation equal to 0 (it depends on the Delta Time, so I assume that the Delta Time when running compiled is much smaller than when running in the Unity Editor) and thus the character didn't move at all.

Cycloplegia answered 30/4, 2013 at 3:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.