Player does not resume movement after re-enabling input

3 days ago 6
ARTICLE AD BOX

This is my PlayerMovement script using Unity Input System.

public class PlayerMovement : MonoBehaviour { public static PlayerMovement Instance { get; private set; } private PlayerInput playerInput; public Vector2 inputVec; public bool canMove = true; void FixedUpdate() { if (!canMove) { inputVec = Vector2.zero; return; } rb2D.MovePosition(rb2D.position + inputVec * moveSpeed * Time.fixedDeltaTime); } public void OnMove(InputAction.CallbackContext context) { if (context.performed) inputVec = context.ReadValue<Vector2>(); else if (context.canceled) inputVec = Vector2.zero; } }

The canMove flag is used to temporarily disable player movement during NPC dialogue, teleportation, or cutscene animations.

The problem

When the player enters a room, I disable movement (canMove = false) and teleport the player to the new map.

After the teleport finishes, I re-enable movement with (canMove = true).

At this point, I expect the player to immediately resume moving if the key is still held down.
Instead, the player remains completely still.

Movement only resumes after the player releases the movement key and presses it again.

Question

Is there a recommended way to handle this situation?

I feel like the input state is somehow being “lost” while canMove is false, but I’m not sure how to restore or re-sync it properly.
Thanks in advance!

Read Entire Article