-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Area2Ds ignore CollisionShape2D.one_way_collision #31564
Comments
The platform in black is a Tilemap and has one_way_collisions, the Player is a KinematicBody2D and it can properly jump through that Tilemap platform, so the problem is really the Area2Ds |
I think that this is not a bug. Edit: I mean only moving physics object will check for one way collisions. |
Further looking into this reveals that, one_way_collision is used only in space_2d_sw.cpp and in the method Space2DSW::test_body_motion |
This makes sense, as Areas are meant to...be areas, and as such, detect overlapping only, not detect collisions, and thus, the collision direction. This doesn't sound like an Area2D bug, but rather a CollisionShape2D bug. or at least a misleading behavior. If One Way Collisions aren't supposed to happen with Areas, which in my opinion they should, since in 3.0 we lost the ability to use CollisionShapes as triggers, thus, there is no other way to achieve that behavior. But anyway, if One Way Collisions aren't supposed to happen with Areas, this property should emit a warning when CollisionShapes are children of Areas and this property |
You are not taking in acount several things. As for Mario physics you do not need the Area at all you just get the normal from the collision. If it faces upwards you just hitted the head of your enemy. |
CollisionShapes are nodes, they can't be sahred between other Nodes, the One Way Collision is a property of CollisionShape nodes, I think you confused them wih the Shape Resources. I don't mean to change the behavior of the CollisionShape, I am proposing to add a warning on the CollisionShape when it is a child of an Area and the One Way Collision is true, otherwise this confusion will keep happening. Another approach is to add support for Areas to take advantage of One Way Collisions, in either case the behavior of the CollisionShape itself won't change. Yeah for the Mario stomp we already solbed the issue using KinematicCollision and checking the collision normal. |
This is still valid, but as others said, it's not a bug. It should be either documented or give a warning. If you want areas support one-way collisions, please fill a proposal on the proposal repository. |
Godot version: 3.1.1
OS/device including version: Solus Gnome
Issue description:
When using CollisionShapes2D and PolygonShape2D to define an Area2D, if we use
one_way_collision = true
it has no effect for the matter of the Area2D signals, it will still emit these signals regardless of the collision directionSteps to reproduce:
one_way_collision
one_way_collision
area_entered
signalThis is a gif of a test I did for a project. It is supposed to mimic Super Mario's stomp mechanic, where the player can jump on enemies' head and by doing so it will hop a bit. The Player's scene has an Area2D (in green) with a CollisionShape2D set as
one_way_collision = true
and rotated by 180 degrees (meaning it should only detect collisions from bottom to top, i.e. with aVector2(0, -1)
collision normal). The enemy's scene (in red) has an Area2D with a CollisionShape2D set asone_way_collision = true
and no rotation (meaning it should only detect collisions from top to bottom, i.e. with aVector2(0, 1)
collision normal).In the .gif, the player is idling and the enemy is moving towards
Vector2(-1, 0)
. Technically, the collision normals should be for the Player's perspective aVector2(-1, 0)
collision and from the enemy's perspective aVector2(1, 0)
collision, I dunno if this is correct, but regardless of the actual normal, none should be neitherVector2(0, -1)
norVector2(0, 1)
. Nonetheless, both Area2Ds (the player's and the enemy's) are triggering their behaviors.The text was updated successfully, but these errors were encountered: