Why doesn't my collision detection between two Area2D objects in Godot 4 work?

In summary, There could be several reasons for two Area2D objects not colliding in Godot 4. Make sure both objects have a collision shape and proper collision layers and masks, and that the nodes are active and enabled. To check if collision detection is happening, use the area_entered or body_entered signals, or print the collision_layer and collision_mask properties. Both signals can be used for collision detection, but the body_entered signal is only emitted for objects with a physics body. If the objects have different collision layers and masks, they will not collide, so make sure they have at least one shared layer and mask. Collision detection can affect performance, so it's important to optimize by disabling it for distant objects or using
  • #1
Darkmisc
213
28
TL;DR Summary
I've followed steps from a tutorial on how to set up collision detection between two Area2D objects. It's not working and I can't figure out why.
Hi everyone

I'd like to detect collisions between a circle and a floor.

I have set them up as follows:

1684196663869.png

1684196709419.png
1684196621540.png


1684196743781.png
The script runs fine (it's just a circle falling towards the floor), but nothing happens when the two objects collide.

Does anyone know what I've done wrong?Thanks
 
Technology news on Phys.org
  • #2
Darkmisc said:
Does anyone know what I've done wrong?
Yes, (1) following a tutorial blindly without thinking and (2) giving up before you have tried to find the problem.

Before you add the 'if body.is_in_group' code you should test to see if the '_on_body_entered' event is firing.
 

Similar threads

  • Programming and Computer Science
Replies
1
Views
1K
Replies
10
Views
1K
  • Programming and Computer Science
Replies
2
Views
2K
  • Programming and Computer Science
Replies
1
Views
1K
  • Programming and Computer Science
Replies
1
Views
1K
  • Programming and Computer Science
Replies
5
Views
1K
  • Programming and Computer Science
Replies
21
Views
3K
Replies
5
Views
935
  • Programming and Computer Science
Replies
2
Views
2K
  • Quantum Physics
Replies
8
Views
1K
Back
Top