I am working on a simple platformer game and so far the controls are working, but will only work for one set of controls at a time, either the Xbox One controller or the keyboard. I want the player to have the option to use either for moving left or right with the character.
But how do I set 2 different inputs to the same float?
With this current code, it still recognizes the controller input, but will only flip the sprite, while the keyboard will flip the sprite and move the character.
float move = Input.GetAxis ("LeftJoystickX");
GetComponent<Rigidbody2D>().velocity = new Vector2 (move * movementSpeed, GetComponent<Rigidbody2D>().velocity.y);
if (move > 0 && !facingRight)
Flip ();
else if (move < 0 && facingRight)
Flip ();
float moveK = Input.GetAxis ("Horizontal");
GetComponent<Rigidbody2D>().velocity = new Vector2 (moveK * movementSpeed2, GetComponent<Rigidbody2D>().velocity.y);
if (moveK > 0 && !facingRight)
Flip ();
else if (moveK < 0 && facingRight)
Flip ();