Skip to content
ItsCubeTime edited this page Jun 4, 2021 · 22 revisions

Physics

Sections

Introduction

Armory is designed to work with any physics engine. Internally, a glue code is written which binds the physics simulation. This lets you pick the most suitable physics engine depending on project needs and makes Armory future-proof.

If no rigid body is detected in the scene, Armory skips including the physics module to save space and performance. To force the physics module, set Armory Project - Modules - Physics from Auto to Enabled.

By default, Armory is configured to use a full featured Bullet physics. If lighter engine is sufficient, Oimo physics is provided. With Oimo, triangle mesh shapes are approximated using convex hulls.

To pick active physics engine, set Armory Project - Modules - Physics Engine property.


Rigid bodies

A rigid body is a type of body that can be used to simulate physical interactions between solid bodies.

Rigid body demonstration

To start using rigid body simulations in Armory, they have to be enabled for Blender first. To do so, simply select the object that will interact in the physic simulation, then go to the Physics properties tab, on the Properties editor, and click on the Rigid Body button.

Enabling rigid body demonstration

If you hit Play (default F5), the object should be immediately free falling out of view:

Free falling demonstration

If this doesn't occur for any reason, you may want to give the troubleshoot section a look.

Types of rigid bodies

Dynamic

Fully simulated physical interactions with other rigid bodies. They are affected by gravity by default.

Static

Objects that don't move during physical interactions with dynamic or kinematic rigid bodies. Not affected by gravity whatsoever.

Kinematic

Objects that are controlled and animated during physical interactions. They are not affected by the physical simulations themselves, but can affect other rigid bodies.

Rigid body configuration

After you click Rigid Body, you will notice that an array of options will appear. These options allow configuring rigid bodies and are explained in details below:

Type

Allow controlling the type of the rigid body when exporting.

  • Active makes the rigid body to be exported as Dynamic if Animated is disabled.

  • Passive makes the rigid body to be exported as Static if Animated is disabled.

Settings

Mass

How much the rigid body "weighs". Important for simulations where more realism is expected, like realistic car movement using vehicle physics.

Dynamic

Controls whether the rigid body is Static when exporting. If disabled, rigid body will be exported as Static instead of Dynamic if Animated is disabled.

Animated

Controls whether the rigid body is exported as Kinematic.

Collisions

Shape

Definition of the shape of the rigid body for the physical simulations. Can be either a primitive: Box, Sphere, Capsule, Cylinder, Cone, which are much better for performance, or Mesh or Convex Hull which are more precise on the shape.

Visual representations of primitives in Blender:

Box Sphere Capsule Cylinder Cone

Non-primitives don't have a visual representation in Blender, but they are mostly based around the original mesh. For convex hull, a new mesh is generated at runtime which is a simplification of the original mesh, and it may look like something like this more or less, at least its outline:

Unlike convex hull, for mesh there is no simplified custom mesh generation, so it's imperative that you create a simplified and maybe even low poly version of the original mesh, to avoid major performance drops.

We can observe the difference between convex hull and mesh by just running a simple physical interaction test:

Mesh Convex hull

Surface Response

Friction

Resistance of the object to movement. Note that other object's friction value affects the result.

Default friction (0.5) for the dynamic rigid body and the static one:

Default friction (0.5) for the dynamic rigid body and 0.0 for the static one:

Bounciness

Tendency to bounce after collision. The greater the value, the more elastic. Note that other object's bounciness value affects the result.

0.75 for both the dynamic rigid body and the static one:

0.25 for both the dynamic rigid body and the static one:

Rigid body Constraints

Along with rigid bodies, Armory also supports Rigid body constraints which lets you limit how a rigid body can move during a physics simulation.

Rigid body physics constraints can be added either through the Logic node editor or from the physics tab in the properties panel. This is not to be confused with "Object constraints" from the object constraints properties panel, which are currently not supported.

Limitations/Known issues:

  • If you want to spawn several instances of the same set of objects using rigid body constraints during runtime (and have them all be active at the same time) you will have to assign the rigid body constraints through either your Haxe or Logic node code. In other words, any rigid body constraints added through the properties panel may not give predictable results in this case. See: https://github.com/QuantumCoderQC/ConstraintVehicleExample

Basics of moving a rigid body

RigidBody API explained


Static bodies

Creating a static body


Trigger bodies

Creating a trigger body


Raycast


Physics World


Vehicle body


Soft bodies

Creating a soft body


Cloth simulation

Creating cloth simulation


Common pitfalls / troubleshoot

Wrong scale may break simulations

Make sure your Blender objects that interact in physics simulations always have scale of (1.0, 1.0, 1.0) inside of Blender. Rotation and location may be arbitrary.

How to check scale and rotation in blender

You can always apply the scale from within Blender by selecting the object, opening the Object menu entry and then navigating to Apply and then clicking on Scale, or simply hitting the shortcut Ctrl + A and then hitting the s key or simply selecting the option from the floating menu.

location of apply rotation and scale option

Low frame rates may break simulations

Generally any game refresh rate below 50 will cause bullet physics to become unstable resulting in objects moving in unpredictable ways "flying around" without being affected by any force other than gravity.

To demonstrate with a vehicle using rigid bodies, rigid body constraints and cylinder based wheels (movement is made using the apply torque node affecting the wheels):

The effects generally get worse with the refresh rate. Note that testing getting these results were only done for this particular scenario, more testing would need to be done to be sure that this cant affect refreshrates above 49 Hz. Testing was done in a packaged Krom game built in Blender 2.93 Beta & the armory build provided here: https://github.com/armory3d/armory/pull/2082.

Clone this wiki locally