+1 vote

Hi all.

I'm trying to disable/enable an area's collision detection after receiving a specific signals.

The Game Over signal will disable the Area2D's collision, and the New Game signal will enable the collision. The code below is from Level.gd.

func _on_BaseArea_area_entered(area):

func _on_HUD_play_game():
score = 0

I was thinking of using setcollisionmask_bit(), but I am having second thoughts.

in Engine by (197 points)

2 Answers

+1 vote
Best answer

If you're using a CollisionShape2D in the area, you can use:

$CollisionShape2D.disabled = true
by (20,475 points)
selected by

Hey, thanks!

0 votes

And sometimes, if you want to change a range of objects in collision you may play with values of collision_mask or collision_layer.

by (164 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.