Comments and answers for "Multiple keys not detected at once"http://answers.unity.com/questions/1560880/multiple-keys-not-detected-at-once.html
The latest comments and answers for the question "Multiple keys not detected at once"Answer by TreyHhttp://answers.unity.com/answers/1560885/view.html
When you manually set velocity like that, you effectively erase whatever physics were acting on your object. While you're accounting for that by only changing the velocity component that corresponds to your key presses, your logical priority here is:
<br><br>
RIGHT: counted above all else
LEFT: only counted when right isn't pressed
UP: only be counted when nothing else is pressed
<br>
You need to incorporate that jump height another way. I don't like changing velocity directly for exactly that reason, but we'll do that here since it's closest to your original setup and the journey is the destination:
<br><br>
// Cache your rigidbody. Either assign this in the inspector
// or do a GetComponent<> from Start or Awake.
//
public Rigidbody rigidbody;
void Update () {
float xvel = rigidbody.velocity.x;
float yvel = rigidbody.velocity.y;
if (Input.GetKeyDown(KeyCode.UpArrow))
{
yvel = jumpHeight;
}
if (Input.GetKey(KeyCode.LeftArrow))
{
xvel = -moveSpeed;
}
if (Input.GetKey(KeyCode.RightArrow))
{
xvel = moveSpeed;
}
rigidbody.velocity = new Vector2(xvel, yvel);
}Mon, 08 Oct 2018 20:12:05 GMTTreyH