You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This parameter seems to change the size of the polygon in the direction of the one-way collision, and the result of this parameter is not identical in Rapier2D. This can be demonstrated if you translate the position of a CharacterBody2D over the margin. In the Godot engine, it will enter the polygon, but the position must be translated further in Rapier2D to get the same results.
This behaviour may be preferable in some scenarios (higher velocities) but is inconsistent with the default engine and the parameter value.
To Reproduce
Translate the position of a CharacterBody2D by the size of the margin into the polygon in the direction of the one-way collision and apply some velocity in the same direction. Using the Godot engine, the body will enter the polygon, but the position must be translated further initially to get the same results using Rapier2D. For example, three pixels for a one pixel margin.
Expected behaviour
I would expect consistent behaviour across engines if the parameter is handled, or clear advice otherwise. It would be very helpful to see in the project settings how the parameters are used by Rapier2D, similar to the Godot parameters that have tooltips and linked documentation.
Using a drop through a one-way platform to demonstrate.
Inputs: Left and right arrow keys to move the CharacterBody2D horizontally, down key to drop one pixel and up key to drop three.
Set-up: CharacterBody2D has a rect collider and the template script with the drops added. Both the static body and tile set have polygon colliders with one-way collisions, pointing down, and default one way collision margins of 1 pixel. All shapes are in the same collision layer.
Result: If Godot 2D engine is used then gravity and the up or down keys allow the CharacterBody2D to pass through, but with Rapier2D only the up key (drop 3 pixels) will allow the body to pass through.
The text was updated successfully, but these errors were encountered:
Thanks, I wasn't sure if this was a bug exactly, but if this parameter is the same in Rapier2D then I guess it is.
I noticed that the one-way collision data is part of the parent class CollisionShape2D (https://docs.godotengine.org/en/stable/classes/class_collisionshape2d.html), so this behaviour may be more general than collisions involving rects and polygons. It seems to depend on the interpenetration in the initial translation.
Describe the bug - inconsistent behaviour with Godot 2D engine
In Godot, a CollisionPolygon2D object has a one-way collision margin parameter (https://docs.godotengine.org/en/stable/classes/class_collisionpolygon2d.html#class-collisionpolygon2d-property-one-way-collision-margin), defaulting to one pixel.
This parameter seems to change the size of the polygon in the direction of the one-way collision, and the result of this parameter is not identical in Rapier2D. This can be demonstrated if you translate the position of a CharacterBody2D over the margin. In the Godot engine, it will enter the polygon, but the position must be translated further in Rapier2D to get the same results.
This behaviour may be preferable in some scenarios (higher velocities) but is inconsistent with the default engine and the parameter value.
To Reproduce
Translate the position of a CharacterBody2D by the size of the margin into the polygon in the direction of the one-way collision and apply some velocity in the same direction. Using the Godot engine, the body will enter the polygon, but the position must be translated further initially to get the same results using Rapier2D. For example, three pixels for a one pixel margin.
Expected behaviour
I would expect consistent behaviour across engines if the parameter is handled, or clear advice otherwise. It would be very helpful to see in the project settings how the parameters are used by Rapier2D, similar to the Godot parameters that have tooltips and linked documentation.
Environment:
Example project(zip)
one_way_test.zip
Using a drop through a one-way platform to demonstrate.
Inputs: Left and right arrow keys to move the CharacterBody2D horizontally, down key to drop one pixel and up key to drop three.
Set-up: CharacterBody2D has a rect collider and the template script with the drops added. Both the static body and tile set have polygon colliders with one-way collisions, pointing down, and default one way collision margins of 1 pixel. All shapes are in the same collision layer.
Result: If Godot 2D engine is used then gravity and the up or down keys allow the CharacterBody2D to pass through, but with Rapier2D only the up key (drop 3 pixels) will allow the body to pass through.
The text was updated successfully, but these errors were encountered: