Update functions while movement (delta?)


Why does my sprint function doesn’t update? Its in the physics_process(delta) function. So it should update every frame, right?
So if move_sprint is pressed. triggers func" sprint"
in the “sprint” function →
is on ground = true and velocity.x != 0 → if you on-ground a doesn’t move: do things

And i thought this func updates every frame, because of the “physics_process(delta) function”

As soon as i leave the ground, things should turn off. But it doesn’t,
If i press move_sprint. things happened until i released the button, if i am on the ground or on midair.

If i press the move_sprint button in midair. Things don’t turn on, even if i touch the ground and move

How to fix this?

func sprint():
	max_speed *= sprint_boost
	acceleration *= 1.1
	sprinting = true
	if on_ground == true and velocity.x != 0:
			sprint_particles.emitting = true
			animated_sprite.speed_scale = 1.5
			print("you sprint/Speed:" + str(velocity.x))
		sprint_particles.emitting = false
		animated_sprite.speed_scale = 1.0

func realesed_sprint():
	max_speed /= sprint_boost
	acceleration /= 1.1
	sprinting = false
	sprint_particles.emitting = false
	animated_sprite.speed_scale = 1.0
	print ("your stopped sprinting ")

func _physics_process(delta: float):
if Input.is_action_just_pressed("move_sprint"):
		if sprinting == false:
	if Input. is_action_just_released("move_sprint"):
		if sprinting == true:
		else :

is_action_just_pressed is only true on the frame the player pressed the action. try is_action_pressed instead.

1 Like