This page has been translated automatically.
Setting Up Development Environment
High-Level Systems
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine and Tools
Double Precision Coordinates
Common Functionality
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
Math Functionality
Node-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
Rendering-Related Classes
Warning! This version of documentation is OUTDATED, as it describes an older SDK version! Please switch to the documentation for the latest SDK version.
Warning! This version of documentation describes an old SDK version which is no longer supported! Please upgrade to the latest SDK version.

Player Actor

A player actor is a player with a rigid physical body, which is approximated with a capsule and has physical properties. Unlike all other players that can move in any direction, the player actor can only walk on the ground.

The viewing orientation of a player actor in space is defined by 2 angles - thetaandphi- and by theupvector that usually coincides with the Z axis:

  • When changing the theta angle, the vertical view direction of the player actor changes.
  • When changing the phi angle, the horizontal view direction and the basis of the player actor change.

Player Actor Approximated with Capsule

As any transformation of a player forces it to recalculate its inner state (position, direction, angles and so on), the up direction of the player's viewport may become "negative forward". And then transformation will be recalculated by using this direction, causing flip of the player's basis. To avoid such flipping, the theta and phi angles should be recalculated by using the current viewing orientation of the player.

By default, the player is positioned in the center of the capsule it is approximated with. To change the position of the player inside the capsule (in other words - set the position of the player's head), use the setOffset()function.

If you need a player actor to go up and down a staircase smoothly, without getting stuck on each stair, you should carefully adjust the radius of the capsule that approximates the player. Or you can approximate the staircase with a plane: in this case, the capsule can be of any radius.

The height of the player's capsule should also be set correctly to avoid getting stuck in a doorway.

A player actor can be used to create a first person view. Also a player actor can be used in pair with player persecutor to create a 3rd person view (see the corresponding samples in the SDK).

See also

  • A PlayerActorclass to edit players via UnigineScript
  • A set of samples located in the data/samples/players/ folder:
    • actor_00
    • actor_01
    • actor_02

Calculating Collisions

When a player actor is not simulated as a rigid body, a simple dummy body with a capsule shape is used to calculate collisions:

  1. All contacts with the shape are found.
  2. The player actor is pushed out of objects it collided with along the contact normal (the global penetration factor is also taken into account here). Effectively, it's a sum of all normal vectors of found contacts.
  3. The velocity change is calculated: the initial velocity vector is projected onto each contact normal (the dot product is calculated) and the result is subtracted from the initial velocity.

Editing Player Actor

In the Player tab, you can adjust the bit-masks and viewing frustum parameters of the player actor.

A Player Tab
Last update: 2017-07-03
Build: ()