-
Notifications
You must be signed in to change notification settings - Fork 400
Physics
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 is a collection of basic geometries (box, sphere). It can also have a mesh collision.
Steps to import mesh collision shape:
- Double click on some model in asset browser
- In opened window, there's
Physics
combobox - Set it to convex or triangle mesh. Note: only convex mesh can be dynamic.
- 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. - Press save button
- There should now be a collision mesh in asset browser
Steps to create rigid actor with mesh collision:
- Create an entity
- Add rigid actor component
- Point rigid actor's mesh property to your collision mesh
- Optionally, you can add box and sphere geometry to any rigid actor
- Optionally, set
Dynamic
property todynamic
if you want your object to be influenced by forces. Note: only convex meshes can be dynamic! - Optionally, set
Dynamic
property tokinematic
if you want to move your object programmatically, but you don't want it to be influenced by forces.
When two rigid bodies collide, contact event is generated and sent to script - function onContact(entity, x, y, z) is called.
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:
Also layers can be added, removed or renamed here.
Layers can be assigned to objects in the property grid:
https://www.youtube.com/watch?v=zJTbv7pBKtk&feature=youtu.be&ab_channel=LumixEngine