How is the correct way of pushing an object with kinematic2D?

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

So, I’m making a 2D platformer and I need the player to push and pull some crates. The player and the objects are KinematicBody2D’s. I tried with raycasting and Area 2D detection, but I can’t get the desired effect.
The player uses the move_and_slide func so I cant get a colliding response. Should I use move_and_collide? and when the player collides with the object, it modifies the motion property of the object?
thanks in advance

:bust_in_silhouette: Reply From: kidscancode

You can get collision response with move_and_slide() by using get_slide_collision(). You get the same KinematicCollision2D response object you’d get with move_and_collide().

See KinematicBody2D.get_slide_collision() for details.

Thanks! I will try it as soon as I can. I didn’t stumble with that in the docs thought

chantunRey | 2019-06-30 19:30