This page has been translated automatically.
UnigineScript
The Language
Core Library
Engine Library
Node-Related Classes
GUI-Related Classes
Plugins Library
High-Level Systems
Samples
Usage Examples
C++ API
API Reference
Integration Samples
Usage Examples
C++ Plugins
Migration
Migrating to UNIGINE 2.0
C++ API Migration
Migrating from UNIGINE 2.0 to UNIGINE 2.1
注意! 这个版本的文档是过时的,因为它描述了一个较老的SDK版本!请切换到最新SDK版本的文档。
注意! 这个版本的文档描述了一个不再受支持的旧SDK版本!请升级到最新的SDK版本。

PlayerActor Class

This class is used to create a player with a rigid physical body. It is approximated with a capsule (of a certain radius and height) and has such physical parameters as mass and friction. It also accelerate and damp its velocity over time. Unlike all other players that can move in any direction, it can only walk on the ground.

The orientation of a character in space (theta and phi angles) are illustrated here.

Each player state (walking, running, etc.) can be accompanied with one of the four helper states:

They appear in the order they are listed above. These states allow you to bind parts of animation to them.

PlayerActor Class

This class inherits from Player

Members


PlayerActor ()

Constructor. Creates a new actor with default properties.

float getAcceleration ()

Returns the current acceleration of the actor.

Return value

Acceleration in units per second squared.

Body getBody ()

Returns a rigid body, if the body is simulated physically (isPhysical(1)); otherwise a dummy body will be returned (isPhysical(0)).

Return value

Actor body.

int getCeiling ()

Returns a value indicating if the actor touches the ceiling surface with its head.

Return value

1 if the actor touches the ceiling; otherwise, 0.

float getCollisionHeight ()

Returns the height of actor's capsule.

Return value

Height in units.

int getCollisionMask ()

Returns the collision mask of the actor. Two objects collide, if they both have matching masks (i.e. at least one bit matches).

Return value

An integer value, each bit of which is a mask.

float getCollisionRadius ()

Returns the radius of actor's capsule.

Return value

Radius in units.

int getCollision ()

Returns a value indicating if collisions with a player's capsule should be taken into account. This method is valid only in case setPhysical() is set to 0 and does not handle collisions automatically.

Return value

Positive number if collisions are taken into account; otherwise, 0.

float getContactDepth (int contact)

Returns penetration depth by the given contact.

Arguments

  • int contact - Contact number.

Return value

Penetration depth.

vec3 getContactNormal (int contact)

Returns a normal of the contact point, in world coordinates.

Arguments

  • int contact - Contact number.

Return value

Normal of the contact point.

Object getContactObject (int contact)

Returns an object participating in the contact with the player (used for collisions with physical object).

Arguments

  • int contact - Contact number.

Return value

Object in contact.

vec3 getContactPoint (int contact)

Returns world coordinates of the contact point.

Arguments

  • int contact - Contact number.

Return value

Contact point.

Shape getContactShape (int num)

Returns a shape that collided with the player's capsule.

Arguments

  • int num - Contact number.

Return value

Shape in contact.

int getContactSurface (int contact)

Returns the surface of the current object, which is in contact (used for collisions with non-physical object).

Arguments

  • int contact - Contact number.

Return value

Surface number.

float getDamping ()

Returns actor's velocity damping with the time.

Return value

Velocity damping.

int getGround ()

Returns a flag indicating if the actor currently stands on the ground surface. This flag is used to determine the actor state, i.e. play the corresponding skinned animation of standing/walking instead of being in the air.

Return value

1 if the actor is on the ground; otherwise, 0.

int getIntersectionMask ()

Returns an intersection mask for a player (masks are considered matching if at least one bit matches).

Return value

An integer value, each bit of which is a mask.

float getJumping ()

Returns a jumping coefficient.

Return value

Jumping coefficient.

float getMaxFriction ()

Returns the friction value set for the actor that is used when the actor doesn't move, i.e. stands still on the ground. See also getMinFriction().

Return value

Friction value.

float getMaxThetaAngle ()

Returns the maximum theta angle (zenith angle, also known as pitch angle) that determines how far downward the player can look. The higher the value, the further down the player can look.

Return value

Angle in degrees.

float getMaxVelocity ()

Returns the velocity of the actor, which is used while the actor runs.

Return value

Velocity in units per second.

float getMinFriction ()

Returns the friction value set for the actor that is used when the actor walks upon the ground. See also getMaxFriction().

Return value

Friction value.

float getMinThetaAngle ()

Returns the minimum theta angle (zenith angle, also known as pitch angle) that determines how far upward the player can look. The lower the value, the further up the player can look.

Return value

Angle in degrees.

float getMinVelocity ()

Returns the default velocity of the actor.

Return value

Velocity in units per second.

int getNumContacts ()

Returns the number of contacts, in which the player's capsule participates.

Return value

Number of contacts.

float getPhiAngle ()

Returns the phi angle (azimuth angle, also known as yaw angle). This angle determines the horizontal viewing direction, i.e. left or right. Positive values rotate the player to the right; negative values rotate it to the left.

Return value

Angle in degrees.

int getPhysicalMask ()

Returns the bit mask for interaction with physicals. Two objects interact, if they both have matching masks (i.e. at least one bit matches).

Return value

An integer value, each bit of which is a mask.

float getPhysicalMass ()

Returns the current mass of the actor.
Notice
If g (Earth's gravity) equals to 9.8 m/s2, and 1 unit equals to 1 m, the mass is measured in kilograms.

Return value

Mass.

ShapeCapsule getShape ()

Returns a shape, which approximates the actor in physical interactions.

Return value

Actor shape.

float getStateTime (int state)

Returns time spent by the actor in a given state.

Arguments

  • int state - One of the PLAYER_ACTOR_STATE_* pre-defined variables.

Return value

Time in seconds spent by the actor in a given state.

int getState (int state)

Returns a value indicating if the actor is in a given state.

Arguments

  • int state - One of the PLAYER_ACTOR_STATE_* pre-defined variables.

Return value

1 if the actor is in the given state; otherwise, 0.

float getThetaAngle ()

Returns the theta angle (zenith angle, also known as pitch angle). This angle determines the vertical viewing direction, i.e. upwards or downwards. If a positive value is returned, the player looks upwards; if a negative value is returned, the player looks downwards. The value is clamped between the minimum and the maximum theta angle.

Return value

Angle in degrees.

float getTurning ()

Returns a velocity of player turning.

Return value

Turning velocity in degrees per second.

int isPhysical ()

Returns a value indicating whether the actor interacts with the environment as a physical object or not.

Return value

Physical flag, 1 if rigid body model is enabled, 0 otherwise.

void setAcceleration (float acceleration)

Sets an acceleration of the actor.

Arguments

  • float acceleration - New acceleration in units per second squared. If a negative value is provided, 0 will be used instead.

void setCeiling (int ceiling)

Sets a value indicating if the actor touches the ceiling surface with its head.

Arguments

  • int ceiling - Positive value to indicate that an actor touches the ceiling; otherwise, 0.

void setCollisionHeight (float height)

Sets a height of actor's capsule.

Arguments

  • float height - New height in units. If a negative value is provided, 0 will be used instead.

void setCollisionMask (int mask)

Sets a collision mask for the actor. Two objects collide, if they both have matching masks (i.e. at least one bit matches).

Arguments

  • int mask - An integer value, each bit of which is a mask.

void setCollisionRadius (float radius)

Sets a radius of actor's capsule.

Arguments

  • float radius - New radius in units. If a negative value is provided, 0 will be used instead.

void setCollision (int collision)

Sets a value indicating if collisions with a player's capsule should be taken into account. This method is valid only in case setPhysical() is set to 0 and does not handle collisions automatically.

Arguments

  • int collision - Positive number to allow collisions, 0 not to handle collisions with the actor.

void setDamping (float damping)

Sets actor's velocity damping with the time.

Arguments

  • float damping - New velocity damping. If a negative value is provided, 0 will be used instead.

void setGround (int ground)

Sets a flag indicating that the actor currently stands on the ground surface. This flag is used to set actor state, i.e. play the corresponding skinned animation of standing/walking instead of being in the air.

Arguments

  • int ground - Positive value to indicate that the actor is on the ground; otherwise, 0.

void setIntersectionMask (int mask)

Sets an intersection mask for a player (masks are considered matching if at least one bit matches).

Arguments

  • int mask - An integer value, each bit of which is a mask.

void setJumping (float coefficient)

Sets a jumping coefficient. The greater the value, the higher the actor jumps.

Arguments

  • float coefficient - Jumping coefficient. If a negative value is provided, 0 will be used instead.

void setMaxFriction (float friction)

Sets a friction value for the actor that is used when the actor doesn't move, i.e. stands still on the ground. See also setMinFriction().

Arguments

  • float friction - Friction value. If a negative value is provided, 0 will be used instead.

void setMaxThetaAngle (float angle)

Sets the maximum theta angle (zenith angle, also known as pitch angle) that determines how far downward the player can look.

Arguments

  • float angle - New maximum angle in degrees in range [0;90]. The higher the value, the further down the player can look.

void setMaxVelocity (float velocity)

Sets the velocity of the actor, which is used while the actor runs.

Arguments

  • float velocity - New velocity in units per second. If a negative value is provided, 0 will be used instead.

void setMinFriction (float friction)

Sets a friction value for the actor that is used when the actor walks upon the ground. See also setMaxFriction().

Arguments

  • float friction - Friction value. If a negative value is provided, 0 will be used instead.

void setMinThetaAngle (float angle)

Sets the minimum theta angle (zenith angle, also known as pitch angle) that determines how far upward the player can look.

Arguments

  • float angle - New minimum angle in degrees in range [-90;0]. The lower the value, the further up the player can look.

void setMinVelocity (float velocity)

Sets the default velocity of the actor.

Arguments

  • float velocity - New velocity in units per second. If a negative value is provided, 0 will be used instead.

void setPhiAngle (float angle)

Sets the phi angle (azimuth angle, also known as yaw angle). This angle determines the horizontal viewing direction, i.e. left or right.

Arguments

  • float angle - New angle in degrees. Positive values rotate the player to the right; negative values rotate it to the left.

void setPhysicalMask (int mask)

Sets the bit mask for interaction with physicals. Two objects interact, if they both have matching masks (i.e. at least one bit matches).

Arguments

  • int mask - An integer value, each bit of which is a mask.

void setPhysicalMass (float mass)

Sets a mass of the actor.
Notice
If g (Earth's gravity) equals to 9.8 m/s2, and 1 unit equals to 1 m, the mass is measured in kilograms.

Arguments

  • float mass - New mass. If a negative value is provided, 0 will be used instead.

void setPhysical (int physical)

Sets a value indicating whether the actor should interact with the environment as a physical object or not (enables or disables its rigid body). If disabled, collisions can be handled using setCollision() method.

Arguments

  • int physical - Physical flag, 1 to enable rigid body model, 0 to disable it.

void setThetaAngle (float angle)

Sets the theta angle of the player (zenith angle, also known as pitch angle). This angle determines the vertical viewing direction, i.e. upward and downward. The value will be clamped between the minimum and the maximum theta angle.

Arguments

  • float angle - New angle in degrees in range [-90;90]. By a positive value, the player looks upward; by a negative one - downward.

void setTurning (float velocity)

Sets a velocity of player turning.

Arguments

  • float velocity - Turning velocity in degrees per second. If a negative value is provided, 0 will be used instead.

int PLAYER_ACTOR_STATE_BACKWARD

Description

A state, in which the player moves backwards.

int PLAYER_ACTOR_STATE_BEGIN

Description

A state, which denotes a beginning of another state like moving forward.

int PLAYER_ACTOR_STATE_CROUCH

Description

A state, in which the player crouches.

int PLAYER_ACTOR_STATE_DISABLED

Description

A state, which means that another state is disabled.

int PLAYER_ACTOR_STATE_ENABLED

Description

A state, which means that another state is enabled.

int PLAYER_ACTOR_STATE_END

Description

A state, which denotes an end of another state.

int PLAYER_ACTOR_STATE_FIRE

Description

A state, in which the player fires their weapon.

int PLAYER_ACTOR_STATE_FORWARD

Description

A state, in which the player moves forwards.

int PLAYER_ACTOR_STATE_JUMP

Description

A state, in which the player jumps.

int PLAYER_ACTOR_STATE_MOVE_LEFT

Description

A state, in which the player moves left.

int PLAYER_ACTOR_STATE_MOVE_RIGHT

Description

A state, in which the player moves right.

int PLAYER_ACTOR_STATE_RUN

Description

A state, in which the player runs.

int PLAYER_ACTOR_STATE_TURN_DOWN

Description

A state, in which the player turns down.

int PLAYER_ACTOR_STATE_TURN_LEFT

Description

A state, in which the player turns left.

int PLAYER_ACTOR_STATE_TURN_RIGHT

Description

A state, in which the player turns right.

int PLAYER_ACTOR_STATE_TURN_UP

Description

A state, in which the player turns up.

int PLAYER_ACTOR_STATE_USE

Description

A state, in which the player utilizes some object.
Last update: 2017-07-03
Build: ()