appsinacup / godot-rapier-physics

Godot Rapier Physics – 2D and 3D physics engine for the Godot game engine. with better stability, performance, liquids, determinism, state serialization and no ghost collisions.
https://godot.rapier.rs
MIT License
421 stars 22 forks source link

signals fire when a scene starts when connected with code. #302

Closed LeeWannacott closed 1 week ago

LeeWannacott commented 1 week ago

Describe the bug

Signals fire when the game/scene starts when connected with code for example:

func _ready() -> void:
    go_to_map.connect("body_entered",_on_player_entered)

NOTE: This doesn't happen when using godot physics, or when connecting signals through the godot editor.

To Reproduce

Steps to reproduce the behavior:

  1. Add area_2d or static_body with a shape and then connect to a signal via code
my_area.connect("mouse_entered",_on_mouse_entered)

func _on_mouse_entered():
  print("signal triggered")

Then start a scene and see if print statement is printed... (without putting your mouse in the area)

Expected behavior

When an Area2D, or Static_body is connected via code it should only fire a signal when its meant to e.g when mouse entered, or area entered etc... not when the game is started.

specs

Godot v4.3.stable - Pop!_OS 22.04 LTS - Wayland - Vulkan (Forward+) - dedicated AMD Radeon RX 6800 XT (RADV NAVI21) - AMD Ryzen 9 5900X 12-Core Processor (24 Threads)

Example project(zip)

NA

Ughuuu commented 1 week ago

Can you add an example project and a video with the problem? My initial guess is it's possible the mouse object gets instantiated at 0,0, or something to do with that. If you can put a project and delete the godot-rapier addons folder when uploading the zip.

LeeWannacott commented 1 week ago

Hmmm, so after further investigation, if two areas are overlapping (and on same collision mask) and a game starts godot physics doesn't trigger the signal whereas rapier2d does. godot physics also doesn't pickup mouse_entered signals on static collision bodies.

I think its rapier2d which is actually correct? and godot physics that is bricked, which makes it look like rapier2d is bugged, but the base implementation in godot is potentially wrong to begin with... either way its a different implementation.

Ughuuu commented 1 week ago

Hm, thats ok. It's possible some things in godot and rapier might be different, some for the worse(eg. adding objects to godot in ready don't immediately work, you need to wait 1 frame I think), in rapier they work. If the difference is huge I can look into making them act closer, if it is a big bug/issue.