What is a kinematic rigidbody?

What is a kinematic rigid body and how are they used in Unity?

If you’ve ever used a Rigidbody component in Unity, you may have seen a couple of settings on the component which may be a little difficult to understand the meaning of. On this site, we have covered what some of these settings mean and what they do, such as:

Discrete collision tunnelling
Tunnelling caused by using the wrong collision mode.
Camera jitter in Unity
Camera jitter which can be fixed by using the correct Rigidbody Interpolate property.

However, we’ve never covered what the Is Kinematic property does in Unity’s Rigidbodies.

Rigidbody Is Kinematic
The Is Kinematic Property on the Rigidbody component.
How to make a Rigidbody2D kinematic
In Rigidbody2D components, you can change the Body Type to get a kinematic.
  1. What is a rigid body?
  2. What is a kinematic?
  3. What are kinematics used for?
    1. Moving platforms
    2. Animated obstacles or platforms
    3. Player characters
    4. Projectiles
  4. Conclusion

1. What is a rigid body?

To understand what is a kinematic, it is helpful for us to first understand what a rigid body is. A term borrowed from physics and engineering, rigid bodies are idealised objects that do not deform under the influence of external forces. Instead, they maintain their shapes and sizes, making them ideal for analysing mechanical systems in physics and engineering.

Angry Birds uses Rigidbodies
If you were to build Angry Birds in Unity, you would be using a whole lot of Rigidbodies.
Image from Tenor.

In Unity, the Rigidbody component does 2 things when attached to a GameObject:

  1. Detects and resolves collisions between colliders. This means that, in every physics frame, it detects all rigid bodies with overlapping colliders and separates them.
  2. Provides physics behaviour. After separating overlapping objects, the Rigidbody component also calculates how these overlapping rigid bodies exert forces on each other after collision.

Typically, Rigidbody components are used for (2), to add physics behaviour to GameObjects, as shown in the animated image above. However, it is also important to note that for Unity to register collisions between 2 GameObjects with colliders, at least 1 of these GameObjects has to have a Rigidbody component. Otherwise, the collision won’t be detected.

Article continues after the advertisement:

2. What is a kinematic?

When you make something a kinematic, what you are essentially trying to do is disable (2), the physics behaviour of a Rigidbody component. This means that a kinematic Rigidbody does not get affected by external forces. In essence, they can still push other rigid bodies, but they cannot be pushed by other rigid bodies.

The short below illustrates this:

Assets from the Cartoon Toyland Pack on the Unity Asset Store.

In a sense, you can also say that kinematic rigid bodies behave like Thor’s hammer.

Note that when you make a Rigidbody kinematic, you will not be able to manipulate it by using rigidbody.AddForce() or rigidbody.velocity any longer. The only 2 ways to move a kinematic Rigidbody are:

  1. By applying animations on them, or;
  2. By moving them with code.

3. What are kinematics used for?

While the imagery of Thor’s hammer makes kinematics sound really cool, they are often used for rather mundane things in video games in reality, such as:

a. Moving platforms

This is actually the best example you can use to explain what kinematics are. As moving platforms are responsible for transporting players from one point to another, they have to have 2 important traits:

  1. They need to be able to collide with objects, otherwise you cannot stand on them.
  2. They cannot be affected by physical forces, or they will be knocked out of their defined paths.

As it happens, kinematic rigid bodies provide these 2 functionalities perfectly.

How the moving platform works.
Pictured: A moving platform

Article continues after the advertisement:

If you’d like to get some code for setting up moving platforms, you can refer to the article below.

b. Animated obstacles or platforms

A close relative to the moving platform, almost anything that is animated and serves as an obstacle or platform of some kind (e.g. elevators) that cannot be moved is usually a kinematic, for the same reasons as the moving platform.

Sliding door is a kinematic
An example of an animated kinematic.
Assets from Sci-Fi Office Pack on the Unity Asset Store.

c. Player characters

Player-controlled characters are often kinematics, because they should not be susceptible to other forces acting upon them when the player is controlling them. There can be exceptions to this case, however, depending on how the mechanics of the player character are coded.

In Unity, if you are using a NavMeshAgent or CharacterController to provide movement to your characters, note that your characters will be unable to push other rigid bodies around by default. If you want that functionality, you will also have to add 1) a collider and 2) a kinematic rigid body to it.

Pushing Rigidbodies with a NavMeshAgent
You will need to make the Rigidbody on the player a Kinematic, or it will interfere with the motion provided by the NavMeshAgent or CharacterController.

d. Projectiles

Projectiles are another obvious candidate for being kinematics. Again, this depends on the mechanics of the projectile itself. If your projectile follows a preset path when fired, then you will want to use a kinematic rigid body to drive it.

Gameplay footage from CHAD, a game we are releasing soon on Itch.

4. Conclusion

I hope this short article helped to give you a clearer idea of what a kinematic is, and when you should use them. If you have any useful information you’d like us to add to the article, please leave it in a comment below!

Article continues after the advertisement:

Leave a Reply

Your email address will not be published. Required fields are marked *

Note: You can use Markdown to format your comments.

For security, use of Google's reCAPTCHA service is required which is subject to the Google Privacy Policy and Terms of Use.

I agree to these terms.

This site uses Akismet to reduce spam. Learn how your comment data is processed.