Player's Foot Dust particle effect doesn't always emit

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By JayH

Hi,

My foot dust particles don’t always fire when the Player lands on the ground. This is especially true for my Player’s shorter jumps.

enter image description here

Here’s part of the script:

#MAIN ROUTINE
func _physics_process(delta):	
	
	#MAIN PLAYER MOVEMENT
	if !climbing :
		#MOVE PLAYER LEFT/RIGHT
		if Input.is_action_pressed("ui_right") :
			myVelocity.x = PLAYERSPEED
			$AnimatedSprite.play("Walk")
			$AnimatedSprite.flip_h = false
			$AnimatedSprite.set_offset(Vector2(1,0))
		elif Input.is_action_pressed("ui_left") :
			myVelocity.x = -PLAYERSPEED
			$AnimatedSprite.play("Walk")
			$AnimatedSprite.flip_h = true	
			$AnimatedSprite.set_offset(Vector2(0,0))
		else:
			myVelocity.x = 0
			if onGround == true:
				$AnimatedSprite.play("Idle")

		#VARIABLE JUMP HEIGHT		
		if Input.is_action_just_pressed("space"):
			myVelocity.y = JUMPPOWER
		elif Input.is_action_just_released("space"):
			myVelocity.y = -JUMPLOW

		myVelocity.y += GRAVITY # ADD GRAVITY TO THE PLAYER


		#SET IF ON THE GROUND OR NOT
		if is_on_floor():
			if not onGround:
				$FootDust.emitting = true #Play Foot Dust Particle
				onGround = true
		else:
			onGround = false
			if myVelocity.y < 0:
				$AnimatedSprite.play("Jump")
			if myVelocity.y > 0 :
				$AnimatedSprite.play("Fall")
				

		myVelocity = move_and_slide(myVelocity, FLOOR) #MOVE PLAYER WALKING

Any ideas?

:bust_in_silhouette: Reply From: adoci

since you are using a Particle2D node then it could be possible you are trying to emit during the particles lifetime. you could try calling $FootDust.restart() before setting $FootDust.emitting = true

I did wonder that myself, but wasn’t sure how to sort it.

After testing it was that the particles hadn’t finished thier cycle, thanks for the info :wink:

JayH | 2022-07-25 16:03