Unity: Should I choose Kinematic, Static or Dynamic for Rigidbody 2D body type?

When dealing with Rigidbody 2D, there are three key body types which determines how a game object move and react to collision. This post is the complete guide on how and when to use them

Rigidbody 2D body types

Static

  • No REAL Rigidbody component attached to them, so physics engine does not consider them to be moving
  • No collision can be applied to them, so OnTrigger and OnCollision will not work.
  • Use case: ground, walls, other any other game object you don’t want the character collide with
Static Rigidbody 2D body

Kinematic

  • Kinematic game objects are entirely driven by scripts, so you have to manually handle the the motion part:MovePosition, MoveRotation
  • Kinematic game objects only process collisions with Dynamic game objects, i.e. bouncing away, and cause OnCollisionEnter event to be sent
  • Use case: you want the character move with more flexibility
Kinematic Rigidbody 2D body

Dynamic

  • Dynamic game objects are entirely driven by game engine (physical engine)
  • The motion of Dynamic game objects are affected by force, velocity and etc
  • The physics engine takes responsibility for resolving their collisions with static, kinematic, and other dynamic objects and rebounding them as needed
  • Use case: game characters, moving game objects, etc
Dynamic Rigidbody 2D body

Physical Layer Collision Matrix Setting

This is especially useful when you want to customize the physical in your game. Say for example, if you have a game object A, with a dynamic rigidbody on layer Room, and you don’t want it collide with other game objects if they are on layer Door, so you set up like this:

Edit -> Project Settings -> Physics 2D:

In the end, the collision between layer Room and layer Door will be ignored.

Reference

Originally published at https://needone.app on June 21, 2020.

--

--

--

needone.app

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Microsoft Bosque : Regularised Programming

Features of

S̶w̶i̶m̶m̶i̶n̶g̶ Staying Afloat in the Open Source Sea

EP.2 - Practical Flash loan on Decentralized Finance (DeFi)

Auto Generate AWS Diagrams

TDD Your Helm Charts

Running ROS2 on IBM Cloud

Issue #3 — Cloud-Native Untangled: 04/18/2022–04/24/2022

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Needone App

Needone App

needone.app

More from Medium

Making a Player move in Unity

Unity’s Cinemachine: Creating a 3rd Person Behavior Using State-Driven Cameras

Screen Space Reflections In Unity

Layer Mask Issues When Not Using Default Layer in Unity 2021