2D Collisions Overlapping in between frames

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By lakshaya

Hi all,

I am seeing some odd behavior with kinematic bodies. One is a moving platform moving up, and one is the player that has velocity added down, so as to stick to the platform.

I am using a custom implementation of move_and_collide for the player object, and using the AnimationPlayer with ‘sync to physics’ on for the platform.

Essentially, I want to be able to leap above the platform even when it is moving up, and I do a collision test to see if the upward velocity for the player results in a collision with the platform. What should happen is that the collision test returns null, so I can exit the moving platform.

However, what I see in between frames, is that the player collision shape has merged a little bit into the moving platform that is moving up. Thus, all my collision tests with upward velocity fail, and my logic does not work.

Any help with this would be greatly appreciated. Thanks.

Lakshaya

:bust_in_silhouette: Reply From: KozelMx

If I understand correctly, you have the problem with a physic body not colliding correctly with another physic body. If that’s correct, you can try by setting the physics FPS (in project settings / physics) with a larger number. This can make the game run with less FPS so I don’t recommend it that much, unless is something under the double. I hope I could help.

Yes indeed.

I had implemented my own custom logic in 3.5 for my character, using move_and_collide(). For moving platforms however, my characters colliders would mesh together with the characters shape for certain frames, throwing off collisiond detection, especially if both were moving in the same direction.

In 4.0, I circumvented the entire issue with the now more powerful CharacterBody. Move_and_slide() helped me, although I don’t fully understand what it does under the hood to fix the bodies meshing together. Hopefully I never have to find out : )

lakshaya | 2022-09-17 16:05