Lumberyard
User Guide (Version 1.21)

PhysX Collider

The PhysX Collider component provides a shape to the physics object. How the object moves or not depends on the PhysX Rigid Body Physics component.

  • If the entity has the PhysX Collider component only, Lumberyard treats the entity as a static collider that doesn't move. This can be useful for creating game objects such as a wall or mountain.

  • If the entity also has the PhysX Rigid Body Physics component, Lumberyard treats the entity as a dynamic collider. Dynamic colliders mean that the entity can move.

You can specify how the entity behaves or interacts with other entities in the PhysX Collider properties. You can also attach multiple PhysX Collider components to an entity, so that you can define different mesh colliders.

The PhysX Collider component requires the PhysX gem.

For more information, see Simulating Physics Behavior with the PhysX System.

PhysX Collider Properties


                PhysX Collider component properties.

The PhysX Collider component has the following properties.

Property Description

Collision Layer

Collision layer on which this collision exists.

For more information, see Collision Layers.

Collides With

Layers in which this collider will intersect.

For more information, see Collision Groups.

Draw Collider

Renders the collider in the viewport. Set this property so that you can view how your entities interact.

Enabled by default.

Trigger

Turns the collider into a trigger.

Offset

Local offset of the collider relative to the entity.

Rotation

Local rotation of the collider relative to the entity.

Material Library

Material assigned to the collider.

Shape

Shape of the collider. You can specify the following:

  • Box

  • Sphere

  • Capsule

For more information, see Primitive Colliders.

If you want to use a custom collider shape, you can specify the following;

  • PhysicsAsset

For more information, see Creating Mesh Colliders.

Radius

(Sphere only)

Radius of the sphere collider.

Sphere takes the largest value in the Scale property in the Transform component and multiplies it with the Radius.

Dimensions

(Box only)

Dimensions of the box collider.

Height

(Capsule only)

Total height of the capsule collider.

If you set a value that is less than twice the Radius, the Height defaults to a value that is twice the Radius.

For example, if the Radius is 5 and you set a Height at 7, this value changes to 10.

Radius

(Capsule only)

Radius of the capsule collider.

You can't specify a value that is greater than half the value for Height.

For example, if the Height is 10, the radius can be a maximum of 5.

Asset Scale

(PhysicsAsset only)

Scale of the asset collider.

Tip

You can use this property to modify the physics collider shape independent of the entity.

PxMesh

(PhysicsAsset only)

The pxmesh asset assigned to the collider (convex mesh only).

For more information, see Exporting a PxMesh Asset.

Creating a Static PhysX Entity

A PhysX entity that is static can interact with other entities, but doesn't move.

To create a static PhysX entity

  1. Create an entity. For more information, see Creating an Entity.

  2. In the Entity Inspector, choose Add Component and then select a Mesh component.

  3. For Mesh asset, select the mesh asset so that your entity is visible, such as a tree_08.cgf.

  4. Add the PhysX Collider component to the entity.

  5. Press Ctrl+G to enter gameplay mode. Your entity is static and doesn't move.

    Example

    The entity has a PhysX Collider component. Because the entity doesn't have a PhysX Rigid Body Physics component, this entity is static.

    
                            PhysX Collider component example entity
                                that is static.

    Note

    • For the Transform component, leave the Static property enabled. This ensures that the mesh doesn't move.

    • If you want your entity to move, add the PhysX Rigid Body Physics component.

Primitive Colliders

When you add the PhysX Collider component to an entity, you can specify the following basic collider shapes:

  • Box

  • Sphere

  • Capsule

These shapes are primitive colliders because there isn't an underlying mesh that represents the shape. They require less performance than other types of colliders and should be used when possible.

Creating Mesh Colliders

The fourth type of collider is an asset collider. You can specify an asset collider when the accuracy of the collider must be precise. For example, you might add an asset collider when you want to specify a custom shape for your entity. To do this, use a mesh to set up the collider geometry and assign a pxmesh asset to the component. It is common to use mesh colliders for static geometry in the scene.

Note

If you want to define your mesh collider to have different properties, you can do the following:

  • Use a third-party tool such as Maya to define your mesh collider and then import the pxmesh asset into Lumberyard Editor.

  • Attach multiple PhysX Collider components to the entity, and then specify different pxmesh assets and properties for each component.

To create a mesh collider

  1. Create an entity. For more information, see Creating an Entity.

  2. In the Entity Inspector, choose Add Component and then select a Mesh component.

  3. For Mesh asset, select the mesh asset so that your entity is visible.

  4. To make the entity dynamic, add the PhysX Rigid Body Physics component.

  5. Add the PhysX Collider component to the entity.

  6. In the PhysX Collider properties, for Shape, select PhysicsAsset.

  7. For PxMesh, specify the pxmesh asset. Your entity has a custom shape and collider geometry.

    
                        PhysX Collider component properties for asset
                            and pxmesh.

    Note

    To generate .pxmesh files for your game project, see Exporting a PxMesh Asset.

    Example

    Instead of a primitive shape, the entity has a pxmesh asset specified for the PhysX Collider component.

    
                            PhysX Collider component with a custom
                                pxmesh asset to create a custom collider shape.

    Note

    Only convex meshes can be used for dynamic colliders. If you assign a non-convex mesh, the collider won't work.

Colliders as Triggers

Colliders can also operate as triggers, allowing them to perform overlap tests that require less processing. Colliders marked as triggers will not have forces applied when they intersect with another collider. Notifications appear when a trigger overlaps with another collider. This is useful for detecting when something enters a certain area or when two objects overlap.

Note

Because triggers don't perform contact resolution, the contact points between a trigger and another collider aren't available.