This page has been translated automatically.
Programming
Fundamentials
Setting Up Development Environment
UnigineScript
High-Level Systems
C++
C#
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine and Tools
GUI
Double Precision Coordinates
API
Bounds-Related Classes
Containers
Controls-Related Classes
Core Library
Engine-Related Classes
GUI-Related Classes
Node-Related Classes
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
Rendering-Related Classes
Utility Classes
注意! 这个版本的文档是过时的,因为它描述了一个较老的SDK版本!请切换到最新SDK版本的文档。
注意! 这个版本的文档描述了一个不再受支持的旧SDK版本!请升级到最新的SDK版本。

PlayerActor Class

Interface for player actor handling.

To use this class, include the UniginePlayerActor.h file.

PlayerActor Class

Members


PlayerActor ()

Constructor. Creates a new actor with default properties.

Math::Vec3 getContactPoint (int contact)

Returns world coordinates of the contact point.

Arguments

  • int contact - Contact number.

Return value

Contact point.

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.

float getMinVelocity ()

Returns the default velocity of the actor.

Return value

Velocity in units per second.

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 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 right; negative values rotate the player left.

float getContactDepth (int contact)

Returns penetration depth by the given contact.

Arguments

  • int contact - Contact number.

Return value

Penetration depth.

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 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 used to set a bit mask.

void setCeiling (int ceiling)

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

Arguments

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

float getPhysicalMass ()

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

Return value

Mass value.

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]. If a positive value is specified, the player will look upwards; if a negative value is specified, the player will look downwards.

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 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.

float getStateTime (int arg1)

Returns time spent by the actor in a given state.

Arguments

  • int arg1 - One of the available states with the STATE_* prefix.

Return value

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

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 used to set a bit mask.

float getCollisionHeight ()

Returns the height of actor's capsule.

Return value

Height in units.

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.

float getCollisionRadius ()

Returns the radius of actor's capsule.

Return value

Radius 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 used to set a bit mask.

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.

Ptr<ShapeCapsule> getShape ()

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

Return value

Actor shape.

int getState (int arg1)

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

Arguments

  • int arg1 - One of the available states with the STATE_* prefix.

Return value

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

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 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.

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 used to set a bit mask.

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; otherwise, 0.

float getTurning ()

Returns a velocity of player turning.

Return value

Turning velocity in degrees per second.

Ptr<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 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.

Ptr<Shape> getContactShape (int num)

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

Arguments

  • int num - Contact number.

Return value

Shape in contact.

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.

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 - 1 to indicate that the actor is on the ground; otherwise, 0.

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.

Math::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.

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.

void setJumping (float jumping)

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

Arguments

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

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.

float getMaxVelocity ()

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

Return value

Velocity in units per second.

float getJumping ()

Returns the current jumping coefficient.

Return value

Jumping coefficient.

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

1 if collisions are taken into account; otherwise, 0.

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 getDamping ()

Returns actor's velocity damping with the time.

Return value

Velocity damping.

float getAcceleration ()

Returns the current acceleration of the actor.

Return value

Acceleration in units per second squared.

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 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 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 it is disabled, collisions can be handled using setCollision() method.

Arguments

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

int getIntersectionMask ()

Returns an intersection mask for a player.

Return value

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

void setTurning (float turning)

Sets a velocity of player turning.

Arguments

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

void setIntersectionMask (int mask)

Sets an intersection mask for a player.

Arguments

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

Ptr<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.

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 - 1 to enable collisions, 0 not to handle collisions with the actor.

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 right; negative values rotate the player left.

Return value

Angle in degrees.

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.

void setPhysicalMass (float mass)

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

Arguments

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

getViewDirection ()

setViewDirection (const Math::vec3 & direction)

Arguments

  • const Math::vec3 & direction

int STATE_FORWARD

Description

A state, in which the player moves forwards.

int STATE_BACKWARD

Description

A state, in which the player moves backwards.

int STATE_MOVE_LEFT

Description

A state, in which the player moves left.

int STATE_MOVE_RIGHT

Description

A state, in which the player moves right.

int STATE_TURN_UP

Description

A state, in which the player turns up.

int STATE_TURN_DOWN

Description

A state, in which the player turns down.

int STATE_TURN_LEFT

Description

A state, in which the player turns left.

int STATE_TURN_RIGHT

Description

A state, in which the player turns right.

int STATE_CROUCH

Description

A state, in which the player crouches.

int STATE_JUMP

Description

A state, in which the player jumps.

int STATE_RUN

Description

A state, in which the player runs.

int STATE_USE

Description

A state, in which the player utilizes some object.

int STATE_FIRE

Description

A state, in which the player fires their weapon.

int NUM_STATES

int STATE_DISABLED

Description

A state, which means that another state is disabled.

int STATE_ENABLED

Description

A state, which means that another state is enabled.

int STATE_BEGIN

Description

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

int STATE_END

Description

A state, which denotes an end of another state.
Last update: 2017-07-03
Build: ()