pe_player_dynamics

#include

Inherits pe_params.

Public Types

enum entype { type_id = ePE_player_dynamics }

Public Attributes

float kInertia
inertia koefficient, the more it is, the less inertia is; 0 means no inertia
float kInertiaAccel
inertia on acceleration
float kAirControl
air control koefficient 0..1, 1 - special value (total control of movement)
float kAirResistance
standard air resistance
Vec3 gravity
gravity vector
float nodSpeed
vertical camera shake speed after landings
int bSwimming
whether entity is swimming (is not bound to ground plane)
float mass
mass (in kg)
int surface_idx
surface identifier for collisions
float minSlideAngle
if surface slope is more than this angle, player starts sliding (angle is in radians)
float maxClimbAngle
player cannot climb surface which slope is steeper than this angle
float maxJumpAngle
player is not allowed to jump towards ground if this angle is exceeded
float minFallAngle
player starts falling when slope is steeper than this
float maxVelGround
player cannot stand of surfaces that are moving faster than this
float timeImpulseRecover
forcefully turns on inertia for that duration after receiving an impulse
int collTypes
entity types to check collisions against
IPhysicalEntity * pLivingEntToIgnore
ignore collisions with this living entity (doesn't work with other entity types)
int bNetwork
uses extended history information (obsolete)
int bActive
0 disables all simulation for the character, apart from moving along the requested velocity
int iRequestedTime
requests that the player rolls back to that time and re-executes pending actions during the next step
int bReleaseGroundColliderWhenNotActive
when not 0, if the living entity is not active, the ground collider, if any, will be explicitly released during the simulation step.

Detailed Description

Determines the dynamics of a living / walking entity

#include 

// Example for how a living (walking) character can be physicalized
void PhysicalizeLiving(IEntity& entity)
{
    SEntityPhysicalizeParams physParams;
    // Set the physics type to PE_LIVING
    physParams.type = PE_LIVING;
    // Set the mass to 90 kilograms
    physParams.mass = 90;

    // Living entities have to set the SEntityPhysicalizeParams::pPlayerDimensions field
    pe_player_dimensions playerDimensions;
    // Prefer usage of a cylinder instead of capsule
    playerDimensions.bUseCapsule = 0;
    // Specify the size of our cylinder
    playerDimensions.sizeCollider = Vec3(0.3f, 0.3f, 0.935f * 0.5f);
    // Keep pivot at the player's feet (defined in player geometry) 
    playerDimensions.heightPivot = 0.f;
    // Offset collider upwards
    playerDimensions.heightCollider = 1.f;
    physParams.pPlayerDimensions = &playerDimensions;

    // Living entities have to set the SEntityPhysicalizeParams::pPlayerDynamics field
    pe_player_dynamics playerDynamics;
    // Mass needs to be repeated in the pe_player_dynamics structure
    playerDynamics.mass = physParams.mass;
    physParams.pPlayerDynamics = &playerDynamics;

    // Now physicalize the entity
    entity.Physicalize(physParams);
}

// Example for how a living (walking) character's move direction can be modified
void MoveLiving(IPhysicalEntity& physicalEntity)
{
    pe_action_move moveAction;
    // Apply movement request directly to velocity
    moveAction.iJump = 2;
    moveAction.dir = Vec3(0, 1, 0);

    physicalEntity.Action(&moveAction);
}