Skip to content

Physics

Mikulas Florek edited this page Sep 23, 2023 · 11 revisions

LumixEngine uses PhysX as physics engine, however it is encapsulated as a plugin, therefore any other physics engine can be used.

There are following physics component types:

  • Rigid body
  • Heightfield
  • Character controller
  • Joints
  • Vehicles

Rigid actor

Rigid actor is a collection of basic geometries (box, sphere). It can also have a mesh collision.

Steps to import mesh collision shape:

  1. Double click on some model in asset browser
  2. In opened window, there's Physics combobox image
  3. Set it to convex or triangle mesh. Note: only convex mesh can be dynamic.
  4. Optionally, check Create prefab with physics to automatically create a prefab with render model and collision shape. This option exists to save time since the prefab can also be created manually.
  5. Press save button
  6. There should now be a collision mesh in asset browser

image

Steps to create rigid actor with mesh collision:

  1. Create an entity
  2. Add rigid actor component
  3. Point rigid actor's mesh property to your collision mesh

image

  1. Optionally, you can add box and sphere geometry to any rigid actor
  2. Optionally, set Dynamic property to dynamic if you want your object to be influenced by forces. Note: only convex meshes can be dynamic!
  3. Optionally, set Dynamic property to kinematic if you want to move your object programmatically, but you don't want it to be influenced by forces.

Contact

When two rigid bodies collide, contact event is generated and sent to script - function onContact(entity, x, y, z) is called.

Collision filters

Collisions can have different outcome for different objects. For example if we want to determine visibility, we do not want raycast to collide with glass. But normal objects (bullets, flies, ...) should collide. Physical layer is a "type" of physical objects and each object is in exactly one layer. Two objects do not collide if their layers do not collide.

Collision matrix (which layer collides with which) can be set in "Physics" window:

Collision matrix

Also layers can be added, removed or renamed here.

Layers can be assigned to objects in the property grid:

Layer

Vehicles

https://www.youtube.com/watch?v=zJTbv7pBKtk&feature=youtu.be&ab_channel=LumixEngine

Clone this wiki locally