Removing and/or disabling Static/Rigidy Body2D?

Godot Version

4.2.2

Question

Hi all,

Another quick question I need to stop forward progress of my character until a specific action has occurred, so, I was thinking of using a static/rigid body 2D as a part of a larger scene and then disabling/removing it after the action occurred. However, I do not know how to how to do this.

Is there any way to to this easily? It’s never cropped up before.

As always if you can help here is a big thankyou in advance!

Regards.

I used some similar code in my platform game to remove coins after the player collected them. I was originally using queue_free() but that was causing trouble with associated code.

The more complicated option:

$AnimatedSprite2D.visible = false
$CollisionShape2D.set_deferred("disabled",true)
1 Like

That was the answer I was looking for :grinning:. Worked a treat.

Thankyou greatly for replying!

1 Like