


GODOT KINEMATICBODY2D CODE
Because of that, you will have to design your code in a way it can handle scenarios where your node is being hit while stopped. When moving it, you need to check if a collision happened either by moving it using move_and_collide or calling get_slide_collision afterwards. In contrast, Kinematic bodies do not notify collisions unless a movement is made. This makes the implementation easier as you know those signals will be triggered on every contact. For instance, every time a body touches a RigidBody it emits a body_entered signal, and a body_exited when the contact stops. Rigid bodies are always detecting collisions and notifying it through signals. For most games, this is not an issue at all, as probably they would require a simplified and sometimes crooked version of physics. This gives you freedom two do whatever you want, with the downside of having to implement everything manually. Kinematic bodies, on the other hand, are not affected by physics. This may look realistic, but for a user-controlled object, it could be frustrating as controls won't feel as responsive as they should. However, before moving to the new direction the body will first deaccelerate to a stop. This makes the movement more realistic, but also harder to control.Īs an example, if a body is moving to left, in order to make it go right you need to apply an impulse in the reverse direction. The physics engine is responsible to calculate the resulting movement and its new position. The only way to move a Rigid body is by applying forces to it, such as impulse, torque, gravity and friction. This impacts how you move and handle collisions with each one of them. The fundamental difference between those two types is that RigidBody is influenced by physics, while KinematicBody is not.

Kinematic and Rigid bodies are two common nodes for dealing with physics and collisions.
