Not colliding with fire trap

Godot Version

version 4.2.1


The fire trap doesn’t activate when the player collides with it, but it activates when the player stands on it for a few seconds. What am I doing wrong?

here’s the video:

here’s the code for collision,

extends Node2D

func _physics_process(delta):
	for i in $Player.get_slide_collision_count():
		var collision = $Player.get_slide_collision(i)
		collision = collision.get_collider()
		print("Collided with: %s" %
		if == "Trampoline":
			var Fire = collision
			Fire.FireHit = true
			if Fire.FireHit == true and Fire.FireOn == true:
			var Box = collision
			Box.BoxHit = true
			$Player.velocity.y = -700

here’s the code for fire trap,

extends AnimatableBody2D

var FireHit = false
var FireOn = false
func _process(delta):
	if FireHit == true and FireOn == false:
	if $AnimatedSprite2D.frame == 3:
		FireOn = true
		FireHit = false

func _on_timer_timeout():
	FireOn = false

here’s the screenshot of my editor:

The video link you provided doesn’t work! (prompts me to login)

Looking at the code of your fire trap, it shouldn’t do anything by default (because both FireHit and FireOn are false). Assuming your script sets FireHit to true, it will start playing the “hit” animation every frame. I don’t see why it would ever reach the third frame that way, so my best guess would be that you reset FireHit back to False somewhere?

The video will display after you log in to Google Drive. If it still doesn’t show the video, please let me know.

The FireHit variable resets back to False in after the 3rd frame because I want to stop the animation on the 3rd frame. Should I reset FireHit to False in instead?

The collision and animation work normally when the player stands on the fire trap, but they do not work when the player runs through the trap.

try fire_hit = false after the 5 second timer

Edith: oh, so it doesn’t work because of $AnimatedSprite because then 2 animations are running. I think the player is running too fast and that’s why the 3rd frame isn’t reached. I can’t watch the video because I’m getting an error message from Google.

Edith I hope I’m not confusing you: Is it even possible in for fireHit and fireOn to be true at the same time?

No. I am logged in. It wants me to “request access”.

Judging by the code you shared, this is what should happen:

  • The fire nodes are initialized, both FireHit and FireOn are false, so the “hit” animation won’t be played. Assuming you’re using a default animation with at least three frames, all fire nodes will reach the third frame eventually and toggle FireOn to true, before starting the “on” animation and a 5 seconds timer.
  • If the player now collides with a fire node, they should die (since FireOn is true already and your code sets FireHit to true as well).
  • If they don’t however, the “on” animation might reach its third frame (assuming it has this many) which will reset the “on” animation to frame 1 and start yet another timer. If so, this process will repeat every 3 frames!

The latter is probably not what you want. That being said, I don’t see how any of this would explain why the player has to stand multiple seconds on a fire trap for it to kill them. There’s nothing in your code that would explain this behavior.