0 votes

enter image description here
I want this kinematicbody (left) to push this rigidbody (right) and make it roll.

To make it roll i presume I'd have to use add_force() or apply_impulse(). But I can't figure out how to detect collision. The best I could come up with is this:

enter code hereextends RigidBody2D
func _ready():
pass
func _process(delta):
if $KinematicBody2D.get_position() == position:
    add_force(Vector2(0,0),$KinematicBody2D.direction*300*delta)

But that's really shitty code, hope it gets the point across.

(I've also been trying it other ways with getslidecount() or get_slide collision(), but the $KinematicBody2D on the code returns null, although it is on the same scene, I'm trying to figure that out too.)

in Engine by (20 points)

1 Answer

0 votes

If you have code that moves the kinematic body, that should be enough: kinematic and rigid bodies always apply forces to rigid bodies they collide with.

As for why get_slide_count returns null, you might need to enable contact monitoring on the kinematic body and set the contacts reported to a number greater than zero. I'm not sure about that though, I'm not very familiar with messing around with slide info from kinematic bodies.

by (620 points)
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.

Categories