How resolving penetration and `collision_priority` work in details?

Godot Version

Godot v4.2.1.stable

Question

Hi. I can’t find any detailed description of how exactly penetration resolving in move_and_slide and what exactly collision_priority in CollisionObject2D does.

I performed some tests with two platforms moving toward player from opposite direction and crushing player and tests with single moving platform crushing player into a static TileMap with collisions.

  1. In first test one platform had collision_priority set to 1 and I tested few different values for the other platform. These test shows that this value is not simple a “priority” because I see a little different behavior for values 20 and 200. It kinda works as priority because player always ends up clipped into platform with lower priority but how big the exact value actually is somehow also matter, not just ordering. So what is the exact meaning of this parameter?
  2. I can’t find collision_priority setting in TileSets. Do TileMaps always have minimal possible priority?
  3. Can I somehow disable penetration resolving in move_and_slide and instead get info about such event and resolve it by myself?
  4. Can I somewhere find more details about exact implementation of algorithm resolving penetrations?
1 Like

2: the priority setting is part of the GridMap type
3: not sure maybe, body_test_motion?

1 & 4: its used here

Thanks!

  1. From docs: “Gridmaps are a tool for creating 3D game levels, similar to the way TileMap works in 2D.” I see priority setting in GridMap but it does not really seem any helpful. I’m working on 2D game. So do I assume correctly that collision_priority is just not supported for TileMaps (nor TileMapLayer)?

EDIT: Just started reading implementation of the method you linked and it doesn’t make me very optimistic. :smiley:

bool GodotSpace2D::test_body_motion(…) {
//give me back regular physics engine logic
//this is madness
//and most people using this function will think
//what it does is simpler than using physics
//this took about a week to get right…
//but is it right? who knows at this point…