Mouse Movement Blocks Keyboard Input

On Windows 10 UWP, using Monogame 3.6 and Visual Studios 2017, I have a 2d game where the player can move left and right with:

currentKeyboardState = Keyboard.GetState(); currentMouseState = Mouse.GetState(); //used later, if player presses //LMB then it fires projectile in direction of cursor float elapsed = (float)gameTime.ElapsedGameTime.TotalSeconds;//time since the last frame is //used to keep player movement smooth, in case of framerate drop // //player movement // if (currentKeyboardState.IsKeyDown(Keys.A))//move player left { //hasten framerate for movement animation millisecondsPerFrame = 200; currentAnimationFrame = "PlayerLeft"; player_X_Pos -= playerMoveSpeed * elapsed;//move player left, multiply by elapsed camPos.X = player_X_Pos;// move camera with player cam.Move(camPos); } else if (currentKeyboardState.IsKeyDown(Keys.D))//move player right { millisecondsPerFrame = 200; currentAnimationFrame = "PlayerRight"; player_X_Pos += playerMoveSpeed * elapsed; camPos.X = player_X_Pos; cam.Move(camPos); } else if (currentKeyboardState.IsKeyDown(Keys.W))//move player up(for ladders) { player_Y_Pos -= playerMoveSpeed; camPos.Y = player_Y_Pos; cam.Move(camPos); } else if (currentKeyboardState.IsKeyDown(Keys.S))//move player down(for ladders) { if (floorRect.Top > PlayerRect.Bottom)//dont let player move through floor { player_Y_Pos += playerMoveSpeed; camPos.Y = player_Y_Pos; cam.Move(camPos); } }

This is inside the update method and works fine. However, when I move the character left or right and then begin to move the mouse, the character continues to move in that direction, as long as the mouse is still moving. Does anyone know what is causing this issue?

It’s fixed in the latest development build.

1 Like

Really a bug??? I was developing my project with the same constructs as the author of the original posting to this thread and did not experience such an issue.

Interesting… :relaxed:

It sure is, thanks! I’ll be sure to keep up-to-date from now on.