Menu
Lumberyard
User Guide (Version 1.14)

Character Physics

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

The Character Physics component adds physical behavior to and configures simulation characteristics for character entities, such as players and enemies.

Character Physics Component Properties

The Character Physics component has the following properties.

Player Dimensions

Player Dimensions determine the character's physical properties.

Use capsule

When selected, uses capsule collider geometry. When not selected, uses cylinder collider geometry.

Collider radius

Radius of collision for the cylinder or capsule geometry.

Collider half-height

Half-height of straight section of collision for the cylinder or capsule geometry.

Height collider

Vertical offset of collision geometry center.

Height pivot

Offset from the central ground position that is considered entity center.

Height eye

Vertical offset of the camera.

Height head

Center of the head geometry.

Head radius

Radius of the head geometry that is used for the camera offset.

Unprojection direction

Unprojection direction to test in case the new position overlaps with the environment. For Auto, enter 0.

Max unprojection

Maximum allowed unprojection.

Ground contact epsilon

The amount that the living entity needs to move upwards before ground contact is lost.

Player Dynamics

Player Dynamics settings control the physics of the entity.

Mass

Mass in kg.

Inertia

Inertia coefficient. For no inertia, enter 0.

Inertia acceleration

Inertia felt on acceleration.

Time impulse recover

Duration after which inertia is forcefully turned on after receiving an impulse.

Air control

Air control coefficient. Values from 0.00 to 1.00.

Air resistance

Standard air resistance.

Use custom gravity

When selected, uses custom gravity. When not selected, uses world gravity.

Nod speed

Vertical camera shake speed after landings.

Is active

If not selected, disables all simulation for the character, except moving along the requested velocity.

Release ground collider

If selected, and the living entity is not active, the ground collider (if present) is explicitly released during the simulation step.

Is swimming

If selected, the entity can swim and is not bound to the ground plane.

Surface index

Surface identifier for collisions.

Limits

You can set the following limits for the Character Physics component.

Min fall angle

Minimum angle of slope at which the entity starts falling.

Min slide angle

Minimum angle of slope at which entity starts sliding.

Max climb angle

Maximum angle of slope that the entity can climb.

Max jump angle

Maximum ground slope angle that entity can jump towards.

Max ground velocity

Maximum surface velocity on which entity can stand.

Collides with Type

The Collides with type settings affect what collisions the character entity can experience.

Terrain

If selected, entity can collide with the terrain.

Static

If selected, entity can collide with static entities.

Rigid body (active)

If selected, entity can collide with active rigid bodies.

Rigid body (sleeping)

If selected, entity can collide with sleeping rigid entities.

Living

If selected, entity can collide with other living entities.

Independent

If selected, entity can collide with independent entities.

EBus Request Bus Interface – PhysicsComponentRequestBus

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.

EnablePhysics

Makes the entity a participant in the physics simulation.

Parameters

None

Return

None

Scriptable

Yes

DisablePhysics

Stops the entity from participating in the physics simulation.

Parameters

None

Return

None

Scriptable

Yes

IsPhysicsEnabled

Queries if the entity's physics component has been enabled.

Parameters

None

Return

Bool – whether physics is enabled

Scriptable

Yes

AddImpulse

Adds an impulse to the entity.

Parameters

Vector3 – an impulse in world space

Return

None

Scriptable

Yes

GetVelocity

Gets the velocity of the entity.

Parameters

None

Return

Vector3 - velocity of the entity to set

Scriptable

Yes

SetVelocity

Sets the velocity of the entity.

Parameters

Vector3 - velocity of the entity

Return

None

Scriptable

Yes

GetAcceleration

Gets the acceleration of the entity.

Parameters

None

Return

Vector3 – acceleration of the entity

Scriptable

Yes

GetAngularVelocity

Gets the angular velocity of the entity.

Parameters

None

Return

Vector3 – angular velocity of the entity

Scriptable

Yes

GetMass

Gets the total mass (kg) of the entity.

Parameters

None

Return

float – the total mass of the entity

Scriptable

Yes

SetMass

Sets the total mass (kg) of the entity.

Parameters

Float – the total mass to set

Return

None

Scriptable

Yes

EBus Request Bus Interface – CryPhysicsComponentRequestBus

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.

GetPhysicsParameters

Passes in any class that inherits from pe_params to retrieve them, such as pe_params_pos.

Parameters

(output) pe_params&

Return

None

Scriptable

No

SetPhysicsParameters

Passes in any class that inherits from pe_params to set them, such as pe_params_pos.

Parameters

const pe_params&

Return

None

Scriptable

No

GetPhysicsStatus

Passes in any class that inherits from pe_status to retrieve them, such as pe_status_pos.

Parameters

(output) pe_status&

Return

None

Scriptable

No

ApplyPhysicsAction

Passes in any class that inherits from pe_action to set them, such as pe_action_impulse.

Parameters

const pe_action&

bool threadSafe

Return

None

Scriptable

No

EBus Request Bus Interface – CryCharacterPhysicsRequestBus

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.

Move

Requests movement from a living entity.

param velocity – Requests velocity (direction and magnitude).

param jump – Controls how velocity is applied within living entity. See physinterface.h, \ref pe_action_move::iJump for more details.

Parameters

const AZ::Vector3& velocity

int jump

Return

None

Scriptable

No

The following is an example of script using the Request Bus Interface.

local ExampleComponent = { Properties = { MoveSpeed = 1.0 } } function ExampleComponent:OnActivate() -- connect to the TickBus so we receive OnTick events self.handler = TickBus.Connect(self, 0) end function ExampleComponent:OnTick(deltaTime, scriptTime) -- Jump modes -- 0 not jumping -- 1 jumping, instant velocity change -- 2 jumping, add to current velocity local jumpMode = 0 -- get this entity's transform local transform = TransformBus.Event.GetWorldTM(self.entityId) -- we want to apply velocity in the forward direction local velocity = transform:GetColumn(1) * deltaTime * self.Properties.MoveSpeed -- request velocity CryCharacterPhysicsRequestBus.Event.RequestVelocity(self.entityId, velocity, jumpMode) end function ExampleComponent:OnDeactivate() -- disconnect from the TickBus self.handler:Disconnect() self.handler = nil end return ExampleComponent