godotengine / godot

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

Collision signals don't work on static and rigid RigidBody2D but do work between rigid and kinematic RigidBody2D #23042

Open fozbstudios opened 6 years ago

fozbstudios commented 6 years ago
I tried. Sorry if dupe **Godot version:**

v3.0.6.stable.official.8314054

OS/device including version:

arch linux (godot package v:aur/godot-bin 3.0.6-1)

Issue description:

collision reporting doesn't work when a RigidBBody2d mode is static but does when its set to kinematic. Steps to reproduce: create two rigid bodies and set one to static collision reporting wont work when properly set up

Minimal reproduction project:

godotBug.zip The 2 folders in the zip are snapshots of my git repo. Full history is retained in both dirs. project is located at godotQWOPProj/project.godot in both dirs and the script where i set up the signals is located at godotQWOPProj/groundLineStaticBody2D.gd though its attached to a RigidBody2d.

eon-s commented 6 years ago

I think it should not report anything on static or kinematic mode, since those kind of bodies do not detect anything and the physics engine do not expect anything from bodies like that either.

Looks more like a bug on the kinematic mode (unless it is a feature).

Chaosus commented 6 years ago

cc @AndreaCatania

AndreaCatania commented 6 years ago

The kinematic body can be moved and it's fine if it keep track of collision. @eon-s Do you think that it should not keep track of collisions?

Also for static body it's expected

eon-s commented 6 years ago

@AndreaCatania I think it is not normal for a kinematic to keep track of collisions (all the implementations I have seen lack of collision awareness except while using special methods like move_*), but if this is intended for rigids in kinematic mode, then it could be really useful and should be documented.

ninao-xyz commented 6 years ago

I'm currently using a few RigidBody2D nodes in kinematic mode on a game I'm working, and the collision detection has been proven quite handy for my use case. If there's no downsides of keeping track of collisions for rigidbodys in kinematic mode, please consider keeping them.

fozbstudios commented 6 years ago

Personally I think that collisions should be possible to be reported ( if monitor is on of course ) for all modes, but please at least keep it for kinematic. How do you all implement reporting collisions with an object that is not supposed to be moved (ex the ground)? At minimum the docs should be updated to reflect the limitations of each type

AndreaCatania commented 6 years ago

Well it's not a limitation, you should track collision of RigidBody and from there perform your calls. I'm not quite sure but the @eon-s reasoning seems correct to me. I want to think about it.

fozbstudios commented 6 years ago

@andrea ok but depending on the ratio of Rigid to kinematic this approach may not make sense. What do we gain by removing this from the kinematic capabilities

AndreaCatania commented 6 years ago

To move the kinematic body you use a query to check if the motion can be performed that also return the list of collided.

So keep track even of physics engine generated collisions could be useless

ninao-xyz commented 6 years ago

To move the kinematic body you use a query to check if the motion can be performed that also return the list of collided.

what if the body (when in kinematic mode) is being moved by an animation player?

eon-s commented 6 years ago

In that case, it is not expecting collisions and may need a trigger to solve overlaps and interruptions on the animation.

fozbstudios commented 6 years ago

is it really that much overhead

AndreaCatania commented 6 years ago

It's not the correct way to move a kinematic

KoBeWi commented 3 years ago

Seems still valid in 3.2.4 beta3