0 votes

So I have two KinematicBody2D. The player and a box that the player should be able to push. First, I coded the collision handler in the player node, and sended a value to a function on the box node, This way it worked.
But now I want to code the collision handler in the box node, so anything that push the box can move it.

When I make the collision code in the box node, only returns collisions on the Y axis, and not of the X axis (wich is what I need) When the player node collides with something, the motion of it sets to zero.. I think it has to do with that, but can't fix it.
I check the collisions, printing the collider if there is a collision with another KinematicBody2D

Any ideas? Thanks in advance!

in Engine by (39 points)
edited by

Please show your code.

    for i in get_slide_count():
       var collision = get_slide_collision(i).collider as KinematicBody2D
       if collision:

This is in the Box node and only prints if the player is colliding on the Y axis (on top of the box) but nothing if collides on the sides.
Previously, this piece of code was on the Player node, and it worked for both axis.

Wouldn't it be better if the kinematicbody collided with a rigid body instead? So instead of the box being a kinamaticbody, you make the box to rigid body and then it would easily get to be pushed. Just a suggestion

Please log in or register to answer this question.

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.