Pressing shift (which referenced in my code) cause me to uncrouch and askip the animation

Godot Version

4.3

Question

Have a basic game that is supposed to become an fps later down the line. Right now I’m working on a crouching player state and I’m having trouble with shift (an input that isn’t referenced in the crouching player state) making me go to idle state if im still and walking if im moving.

func _update(delta):
	PLAYER._update_gravity(delta)
	PLAYER._update_input(SPEED, ACCELERATION, DECELERATION)
	PLAYER._update_velocity(delta)
	
	if Input.is_action_just_pressed("crouch"):
		_uncrouch()

func _uncrouch():
	ANIMATION.speed_scale = 1.0
	if CROUCH_SHAPECAST.is_colliding() == false:
		ANIMATION.play("crouch", -1.0, -CROUCH_SPEED, true)
		await ANIMATION.animation_finished
		if PLAYER.velocity.length() == 0:
			transition.emit("IdlePlayerState")
		else:
			transition.emit("WalkingPlayerState")
	elif CROUCH_SHAPECAST.is_colliding() == true:
		await get_tree().create_timer(0.1).timeout
		_uncrouch()

  1. Is it the Right Shift and the Left Shift keys both?
  2. Are there any other keys that do this?
  3. What is the Shift key mapped to?
  4. Are there any other methods or objects that use the Shift key to do anything?
1 Like
  1. both shift keys
  2. not as far as i can tell
  3. sprint key
  4. found my mistake thanks for helping i can’t believe i didn’t notice this before

my code for the rest of the switching between player states was in a new function i made called update but for sprint for some reason i used the input function and the InputEvent parameter. Switched it to the update function and now the issue is fixed

There you go! I was hoping those questions would be enough to help you find the answer!

1 Like