godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
89.17k stars 20.22k forks source link

Area2d _on_body_entered Signal activation on scene load when body is in the same scene #97285

Closed Kiwi-the-Cat closed 4 hours ago

Kiwi-the-Cat commented 4 hours ago

Tested versions

Happens consistently in 4.3 project, not reproducible on any other project

System information

Godot v4.3.stable - Pop!_OS 22.04 LTS - X11 - Vulkan (Forward+) - dedicated NVIDIA GeForce GTX 1650 (nvidia; 560.35.03) - Intel(R) Core(TM) i5-9300H CPU @ 2.40GHz (8 Threads)

Issue description

When CharacterBody2D and Area2D are in the same scene, the signal _on_body_entered always activates, weather they are colliding or not

Steps to reproduce

1 - Have a characterBody2D and Area2d in the same scene 2 - Signal to Node2d _on_body_entered 3 - run scene

Minimal reproduction project (MRP)

operationbirthday (copy).zip

AThousandShips commented 4 hours ago

The bodies are colliding though? The Ava area and the Collision static body area colliding, if you move either of the collision shapes away it stops happening, I don't see any issue here

It doesn't collide with the body, it collides with the Collision static body, check with:

func _on_ava_body_entered(body: Node2D) -> void:
    #get_tree().change_scene_to_file("res://Scenes/SecretAva.tscn")
    print("Hello ", body)

And you will see that it prints: Hello Collision:<StaticBody2D#XXX>

It still happens regardless if the Player body is in the scene

Kiwi-the-Cat commented 4 hours ago

The bodies are colliding though? The Ava area and the Collision static body area colliding, if you move either of the collision shapes away it stops happening, I don't see any issue here

It doesn't collide with the body, it collides with the Collision static body, check with:

func _on_ava_body_entered(body: Node2D) -> void:
  #get_tree().change_scene_to_file("res://Scenes/SecretAva.tscn")
  print("Hello ", body)

And you will see that it prints: Hello Collision:<StaticBody2D#XXX>

It still happens regardless if the Player body is in the scene

That's it I'll have to be more careful of what's touching then Thanks!

AThousandShips commented 3 hours ago

You're welcome! In the future I'd suggest asking in the other community channels to make sure something is actually a bug