godot-xr-tools icon indicating copy to clipboard operation
godot-xr-tools copied to clipboard

godot-xr-tools/addons/godot-xr-tools/functions/movement_crouch.gd: changes PlayerBody height from bottom down causing it to stick on release in thin colliders

Open GeminiSquishGames opened this issue 1 year ago • 0 comments

When using thin mesh or terrain colliders, (eg, height map shape, Zylann's hterrains or Zylann's voxel terrains module), and probably general concave collision shapes as well, the PlayerBody's collider is snapped from it's bottom in one frame down into the thin collider when .clear() is applied to the dictionary _player_height_overrides. So when the crouch is released the PlayerBody is stuck rather than standing. This should probably be done in a way that changes height from the top so it doesn't snap through these colliders. Preferably smooth. This is observed in #384 but not very well explained.

update: After looking at things, I'm not certain, but it could probably be fixed better with more work on the Godot Physics engine rather than the XRTools. The colider being stuck doesn't seem to be something that should happen at a lower level maybe? I will try and look into that as well as trying another physics engine if I can find one with a module. Still will have to work around it some how since none of my outdoor levels will work with it.

update: My work around, though probably a terrible idea: @ line 74: ` #Update crouching state

if crouching != _crouching:
    _crouching = crouching        
    if crouching:
        player_body.override_player_height(self, crouch_height)
    else:                  
        player_body.override_player_height(self)
        player_body.position.y += crouch_height # added to pop out of certain colliders`

It "seems" to work with the height map collider node, and Zylann's hterrains and voxel terrains collisions, but needs peer review and further investigation I feel.

GeminiSquishGames avatar Jul 18 '23 07:07 GeminiSquishGames