Slow Area2D monitorring

Godot version:
4.1.1

I want to make breakable blocks in my game, which I’m doing by using area2D’s around the breakable edges of the block, with a function that destroys the blocks when the body_entered signal triggers. The signal only triggers about half a second after the player enters the area2D though, which makes it so the block is still there for a while before disappearing. How can I fix this?

Here’s a picture of my block + it’s area2D’s

And here’s my code:

extends StaticBody2D

func on_area_2d_body_entered(_body):
if globals.mach_2 == true:
destroy()
print(“swag”)

func _on_area_2d_2_body_entered(_body):
if globals.crashdown and globals.crashdistance > 225:
destroy()

func destroy():
$Sprite2D.visible = false
$CollisionShape2D.disabled = true

It shouldn’t trigger so slowly, are you sure the collision shape of the player is in the right place?

1 Like

Yeah, it’s just a circle so I don’t know why that would matter
image

Quick question: how many of these blocks are on the level?

1 Like

Currently there’s only 3 of them, here’s a screenshot.

I’ve tried to find a way to make the entire node remove itself, but I couldn’t find out how lmfao. I’ve tried PROCESS_MODE_DISABLE but I couldn’t figure out how that works, and i tried get_tree().quit() but that also didn’t work. I thought this was a nice workaround.

(Also oops i deleted my last post instead of editing, im still new to this site haha)

Ok, now that it’s in context, that hitbox is really small. Either make it bigger or just use the block’s colission shape itself to check.

1 Like

I’ve already tried that too, but that’s not a good option. Even if I make them this big, the collision of the block will hit my player character before it disappears and cause it to lose all momentum. Which sucks, because momentum is a big mechanic in my game.

I partially found it out. Using queue_free() helped, but my character still gets slowed a bit by the impact of the blocks even if i make the collision very small.

Okay I finally really solved it !! Turns out i should’ve just increased the physics steps per frame. Now it works !!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.