Godot Version
4.4.1
Question
I add two nodes to the world like this:
- Instantiate.
- Set
position
somewhere far away to avoid it being spawned in the world origin. - add_child.
- Set global_position (in the video i use the mosue global position as is visible).
Let’s call the two nodes C and R.
C has a CircleShape2D and R has a RectangleShape2D as collision shapes. Both are CharacterBody2D.
Ignore all the unnecessary code in the video I removed it during testing, the bodies had no scripts and were not touched in any way except as described above.
Around the origin I have an Area2D which uses the body_entered signal and prints out which nodes enter.
Here’s the problem.
The body C (circle shape) is detected by the Area2D above when C is added to the tree.
But (!) body R (rectangle shape) is not detected by the Area2D.
I can add 1000 of body C nodes and all get detected, so it’s not a fluke.
I can add 1000 of body R nodes and none get detected, so it’s not a fluke.
Now, if I change the body C’s collision shape from CircleShape2D to RectangleShape2D then it’s no longer detected and everything works the same way as the body R.
I’m lost. Why does this happen, please?
How do you even move a node with a circle shape before adding it to the world to avoid unnecessary detection like this, please?
So far I was not able to create an MRP.
What I tried in my project was:
Create a new CharacterBody2D, give it no script at all. Add an Area2D node with body_entered signal connected to a method printing the name of the body. Try circle shape - gets detected - then try the rectangle shape - doesn’t get detected. So I don’t think this has anything to do with my code but with some godot setting maybe or just something going weird?
Video: https://youtu.be/mlu7ipj7cb8
I’d appreciate your advice, I’m so confused at this point.
Thank you very much!