+3 votes


When using a KinematicBody, there is a useful move_and_collide() method which allows the user to move the body while preventing it from clipping through other collision bodies. What is the best way to emulate this behaviour with a RigidBody in MODE_KINEMATIC?


I have implemented a FPS puzzle game (in Godot 3.0 alpha 2) where the player can pick up and position objects (e.g. putting a box on a table). The objects which can be picked up are currently KinematicBodies and the collision detection is handled by using KinematicBody's move_and_collide() method to prevent the objects from clipping through other objects.

However, I realised that, when you put an object down, gravity needs to act on the object. Accordingly, I converted the KinematicBodies into RigidBodies and specified that they should be in MODE_KINEMATIC when being carried by the user (switching back to MODE_RIGID when dropped). However, my original code did not work any more because the move_and_collide and move_and_slide methods are no longer available.

I have created a GitHub issue asking whether it is possible to make KinematicBody methods available when RigidBody is in kinematic mode - see here:


However, in the interim, I would be grateful for any suggestions as to how best to emulate KinematicBody's move_and_collide() method for RigidBody in Kinematic mode? Presumably this would need to be handled somehow in the _physics_process() callback? Also, the docs state here that:

As a warning, don't change RigidBody's position every frame or very
often. Sporadic changes work fine, but physics runs at a different
granularity (fixed hz) than usual rendering (process callback) and
maybe even in a separate thread, so changing this from a process loop
will yield strange behavior.

Is this warning relevant when the RigidBody is in kinematic mode? If so, how can we move the RigidBody so that it follows the player's first-person view while being 'carried' by the player?

Surely it can't be impossible to implement an object that can be picked up and then become subject to gravity when put down?

in Engine by (21 points)

Just a thought, hypothetical:
you could juggle a node between being RigidBody and KinematicBody. Anytime you'd need either "feature" you would cast a RigidBody up to PhysicsBody then back down to KinematicBody and the other way around. In C++ you have cast_to<t>() where t is your target class. IDK how casting works in GDScript, though.

Many thanks for this suggestion - I'll give this a try this weekend! I am using GDScript exclusively so I'll first need to check whether it's possible (and, if so, how) to do the casting you describe...

Well, I don't know... it's a long shot and it might not work (hence "hypothetical" :D). I didn't get to test it. It theoretically works but you loose some info on casting upwards.

1 Answer

0 votes

I'm using TestMotion which allows you to at least check whether the movement would be valid. But I agree that the methods you mentioned would seem to better suit this use case.

by (39 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.