Question by
paradauxtm · Dec 07, 2017 at 10:04 PM ·
c#unity 5
Keyboard input works in editor, but not when built
Hi,
So I've recently gotten into Unity, and have made a Unity Space Shooter Game. However when trying to build it I seem to be getting this strange problem where it won't take input from any of the arrow keys, or wasd keys. Even though they have been setup as keys to take input from. It gets weirder because I'm shooting with my spacebar and that works perfectly fine.
In terms of code for my movement I have:
void FixedUpdate()
{
float horizontalMov = Input.GetAxis("Horizontal");
float verticalMov = Input.GetAxis("Vertical");
Vector2 velocity = new Vector2 (horizontalMov, verticalMov);
move (transform, velocity * speed);
}
void move (Transform pos, Vector2 moVector) {
float multiplier = 1.0f;
if (moVector.y > 0) {
multiplier = 1.2f;
} else if (moVector.y < 0) {
multiplier = 0.8f;
}
Vector2 movePlayer = new Vector2 (moVector.x, moVector.y * multiplier);
pos.position = Vector2.Lerp (pos.position, pos.position + new Vector3 (movePlayer.x, movePlayer.y, 0), Time.deltaTime);
}
I've tried editing they keys when I run the game, but it doesn't work / do anything differently. I'm incredibly stuck and grateful for any help I receive.
Thanks in advance.
keysetup.png
(36.1 kB)
Comment