- Edited
Hi,
I am new to Godot so I might be missing something obvious here, but the following behavior seems like a bug to be:
I have a RigidBody2D
scene node with a CollisionShape2D
subnode. I am using a capsule shape, but this seems to be irrelevant for the problem, I tried it with other shapes, too. The RigidBody2D
has a GDScript assigned, which listens to input_event
from CollisionShape2D
to detect a mouse click inside the collision shape, the connected function looks like this:
func _on_input_event(viewport, event, shape_idx):
if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT and event.pressed:
print("clicked on TestRigidBody")
self.position += Vector2(0.0, 50.0)
I then have my main scene derived from Node
which instantiates this RigidBody2D
scene (named TestRigidBody
) and just moves it at a start position like this:
func _ready():
var screen_size = DisplayServer.window_get_size()
$TestRigidBody.position = 0.5 * Vector2(screen_size.x, screen_size.y)
The problem now arises when the user clicks on the TestRigidBody
: At first everything works fine and the rigid body and its collision shape seem to be moved by Vector2(0.0, 50.0)
as intended. I enabled "Debug->Visible Collision Shapes", which shows the collision shape is moving, too. But when trying to click inside the collision shape again to move the object once more, only a click inside the initial collision shape triggers the _on_input_event
function not a click inside the actual visualized collision shape. So essentially it seems that the collision shape of TestRigidBody
has not moved at all when clicking on the object, although godot debugger shows the visualized collision shape in the intended place.
Am I right in assuming this is a bug and do you know how to circumvent it?
I tested this in Godot 4.0.3 and Godot 4.1 dev3 running on an Intel mac. I attached a test project with the above setup for you to see the problem in action:
Have a nice day!