Menu
Lumberyard
User Guide (Version 1.13)

Shapes: Cylinder, Capsule, Box, Sphere, Compound

Component entity system is in preview release and is subject to change.

The Shape components provide generic shape facilities for components that use shapes. The shape component helps to define the following:

  • Trigger Volumes

    Use shapes as volumes to specify triggering bounds.

  • Collision Volumes

    Use shapes as volumes to specify collider bounds.

  • Audio Area Ambiances

    Uses shapes as volumes in which a reverb is applied.

  • Audio Areas

    Uses shapes as volumes in which a sound plays.

Only one shape component can be attached to any particular entity. If you need more than one shape on a single entity, you can create child entities, then add shape and components to them.

Each shape component provides a generic 'ShapeService' that exposes functionality common to all shapes. Each shape also provides a more specific service, such as 'BoxShapeService' and 'SphereShapeService'.

The Shapes component includes the following shapes and its properties:

  • Cylinder Shape – Define Height and Radius in meters.

  • Capsule Shape – Define Height and Radius in meters.

  • Box Shape – Define dimensions X, Y, and Z in meters.

  • Sphere Shape – Define Radius in meters.

  • Compound Shape – Use picker (hand icon) to select two or more shapes to combine. With the compound shape component, you can combine shapes to create a complex object that you can use to generate a physics collider or a trigger shape, or any other application of shapes. The individual shapes may or may not be children of the entity with the compound shape component. To move the shapes independently of the entity with compound shape, do not set them as child entities. To move them together with the compound shape, set them as child entities. Compound Shapes service the full shape component bus; however, note that each individual shape added increases the cost of requests such as IsPointInside.

ShapeComponentRequestsBus

Use the following request functions with the EBus interface to communicate with other components of your game.

For more information about using the Event Bus (EBus) interface, see Working with the Event Bus (EBus) System.

GetShapeType

Allows users to fetch the type of shape that this component is using.

Parameters

None

Return

AZ::Crc32(shape_name)

For example: AZ::Crc32("Box") | AZ::Crc32("Sphere") | AZ::Crc32("Capsule") | AZ::Crc32("Cylinder")

Scriptable

Yes

GetEncompassingAabb

Returns an AABB that encompasses this entire shape.

Parameters

None

Return

AZ::Aabb that encompasses the shape

Scriptable

No

IsPointInside

Checks if a given point is inside a shape or outside it.

Parameters

point Vector3 – The point to be checked

Return

bool indicating whether the point is inside or outside

Scriptable

Yes

DistanceFromPoint

Returns the minimum distance between a specified point and the shape.

Parameters

point Vector3 – Point from which to calculate distance

Return

type: float

Distance from point to shape

Scriptable

Yes

DistanceSquaredFromPoint

Returns the minimum squared distance between a specified point and the shape.

Parameters

point Vector3 – Point from which to calculate square distance

Return

type: float

Square distance from point to shape

Scriptable

Yes

ComponentRequestsBus

Each shape component has its own specific Ebus that can be used to access and use the services of that particular shape. All these buses are similar to each other and differ only in the types being serviced.

BoxShapeComponentRequestsBus

Fetches the configuration of the BoxShape.

Name

GetBoxConfiguration

Parameters

None

Return

BoxShapeConfiguration object which provides access to the box configuration

Scriptable

Yes

SphereShapeComponentRequestsBus

Fetches the configuration of the SphereShape.

Name

GetSphereConfiguration

Parameters

None

Return

SphereShapeConfiguration object which provides access to the sphere configuration

Scriptable

Yes

CapsuleShapeComponentRequestsBus

Fetches the configuration of the CapsuleShape.

Name

GetCapsuleConfiguration

Parameters

None

Return

CapsuleShapeConfiguration object which provides access to the capsule configuration

Scriptable

Yes

CylinderShapeComponentRequestsBus

Fetches the configuration of the CylinderShape.

Name

GetCylinderConfiguration

Parameters

None

Return

CylinderShapeConfiguration object which provides access to the cylinder configuration

Scriptable

Yes

CompoundShapeComponentRequestsBus

Fetches the configuration of the CompoundShape.

Name

GetCompoundShapeConfiguration

Parameters

None

Return

CompoundShapeConfiguration object which provides access to the compound shape configuration

Scriptable

Yes

ShapeComponentNotificationsBus

OnShapeChanged

Informs listeners that the shape component has been updated, meaning that the shape was modified.

Name

OnShapeChanged

Parameters

ShapeChangeReasons Indicates whether the shape has to be updated due to either a transform change or a shape parameters change.

Return

void

Scriptable

Yes