0 votes

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 moveandslide func so I cant get a colliding response. Should I use moveandcollide? and when the player collides with the object, it modifies the motion property of the object?
thanks in advance

in Engine by (39 points)

1 Answer

+1 vote
Best answer

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.getslidecollision() for details.

by (19,905 points)
selected by

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

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.