How to detect collisions while changing position for a kinematicbody

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

Hi, I have made moving platforms for my platformer in which there is a kinematic body with two tweens attached to it,one for moving the platform and one bringing it back and it continues in a loop.

But what I have noticed is that it does not detect collision and stop while its changing its position.

Does anyone have a solution for this?

If I understand correctly, your platform is a KinematicBody and you you want it to stop when it collides with something? What can the platform bump into that would make it stop? Platforms may support only one-way collisions, so do you want the platform to stop when something lands on it, or is it a block that supports collisions in all directions (like bumping into a wall)?

First of all, if you are using Tweens to move a kinematicbody using their position member, I think that is your issue as to why collisions aren’t occurring. move_and_slide and move_and_collide are designed to move Kinematicbodies and have them stop when they bump into something.

godot_dev_ | 2022-08-17 15:40

:bust_in_silhouette: Reply From: SteveSmith

Use Areas to detect the collisions.