So i am making a game where the default key bindings change to different key bindings after the player passes a checkpoint. I made a Area2D checkpoint and connected the node and here's the code below

func _on_Area2D_body_entered(body):
	if body.name == "Player":
		var ev
		ev = InputEventKey.new()
		ev.scancode = KEY_X
		InputMap.action_erase_events("ui_right")
		InputMap.action_add_event("ui_right",ev)

The key bindings change successfully. there's no issue there but the player moves automatically until the new key "x" is pressed

  • for anyone who face the same issue in the future, I fixed this issue by adding the following code but the player stops for some milliseconds which is not smooth
    Input.parse_input_event(ev)

Can you add a tag indicating which version of Godot you are using? Or share it here and I can tag it for you.
(Also, I fixed the code formatting 🙂)

    for anyone who face the same issue in the future, I fixed this issue by adding the following code but the player stops for some milliseconds which is not smooth
    Input.parse_input_event(ev)