Skip to content

YaCharacterAPI

YaCharacterAPI manges Characters in the game. Characters are player-controlled avatars or NPCs in the scene.

Functions

boolean YaCharacterAPI.IsPlayerCharacter(YaEntity entity)

ReturnsTrue if, is player character
Checks if the entity is controlled by the player.
  • entity Entity

YaEntity YaCharacterAPI.GetPlayerEntity(YaEntity characterEntity)

ReturnsPlayer Entity
Gets the player entity.
  • characterEntity Character entity

void YaCharacterAPI.OnPush(function callback<YaEntity, YaEntity, float3, number>)

SERVER ONLY 
Fired when the Character is pushed
  • callback Callback function
    1. target The target Character to be pushed
    2. trigger The entity that pushes the Character
    3. direction The direction in which the Character is pushed
    4. distance The distance at which the Character is pushed

void YaCharacterAPI.OnFall(function callback<YaEntity, number>)

SERVER ONLY 
Fired when the Character falls
  • callback Callback function
    1. target The target Character to fall
    2. fall height Fall height

void YaCharacterAPI.OnGround(function callback<YaEntity, number>)

SERVER ONLY 
Fired when the Character lands on the ground
  • callback Callback function
    1. target The target Character landing on the ground
    2. fall height Fall height

void YaCharacterAPI.OnStartSwim(function callback<YaEntity>)

SERVER ONLY 
Fired when the character starts swimming
  • callback Callback function
    1. target The target Character that starts swimming

void YaCharacterAPI.OnEndSwim(function callback<YaEntity>)

SERVER ONLY 
Fired when the character stops swimming
  • callback Callback function
    1. target The target Character that stops swimming

void YaCharacterAPI.OnEnterHit(YaEntity character, function callback<YaEntity, number, float3>)

SERVER ONLY 
Character hit enter
  • character character
  • callback Callback function
    1. hitEntity Hit entity
    2. site The site of contact 0:side 1:Up -1:Down
    3. normal The normal direction of the contact point

void YaCharacterAPI.OnExitHit(YaEntity character, function callback<YaEntity>)

SERVER ONLY 
Character hit exit
  • character Character
  • callback Callback function
    1. hitEntity Hit entity

void YaCharacterAPI.OnPush(YaEntity character, function callback<YaEntity, float3, number>)

SERVER ONLY 
Current character be pushed event
  • character Character
  • callback Callback function
    1. pusher The entity that pushes the Character
    2. direction The direction in which the Character is pushed
    3. distance The distance at which the Character is pushed

void YaCharacterAPI.OnFall(YaEntity character, function callback<number>)

SERVER ONLY 
Current character fall event
  • character Character
  • callback Callback function
    1. fallHeight Fall height

void YaCharacterAPI.OnGround(YaEntity character, function callback<number>)

SERVER ONLY 
The current character landing event
  • character Character
  • callback Callback function
    1. fallHeight Fall height

boolean YaCharacterAPI.IsCharacter(YaEntity entity)

ReturnsTrue if the entity is a Character
Checks if the entity is a Character.
  • entity Entity

boolean YaCharacterAPI.IsDead(YaEntity entity)

ReturnsTrue if the Character is dead
True if the Character is dead, otherwise false.
  • entity Entity

number YaCharacterAPI.GetCurrentMoveSpeed(YaEntity character)

ReturnsMove speed (m/s)
Get current move speed. Returns only the movement speed in the horizontal direction
  • character Character

number YaCharacterAPI.GetCurrentMoveDirection(YaEntity character)

ReturnsIn y-rotation radians
Gets the direction of the character's movement, expressed in y-rotation radians. The direction of movement may differ from the direction of character rotation if the character is retreated
  • character Character

number YaCharacterAPI.GetCurrentVerticalSpeed(YaEntity character)

ReturnsSpeed (m/s)
Gets the speed in the current vertical
  • character Character

boolean YaCharacterAPI.IsGrounded(YaEntity character)

ReturnsIs true, character is on the ground
Whether the character is on the ground
  • character Character

boolean YaCharacterAPI.IsJumping(YaEntity character)

ReturnsIs true, character is jumping
Whether the character is jumping
  • character Character

boolean YaCharacterAPI.IsMoving(YaEntity character)

ReturnsIs true, character is moving
Whether the character is moving
  • character Character

boolean YaCharacterAPI.IsWalking(YaEntity character)

ReturnsIs true, character is walking
Whether the character is walking
  • character Character

boolean YaCharacterAPI.IsRunning(YaEntity character)

ReturnsIs true, character is running
Whether the character is running
  • character Character

boolean YaCharacterAPI.IsSwimming(YaEntity character)

ReturnsIs true, character is swimming
Whether the character is swimming
  • character Character

void YaCharacterAPI.SetWalkMaxSpeed(YaEntity character, number value)

SERVER ONLY 
Set the maximum walking speed
  • character Character
  • value Max speed (m/s)

number YaCharacterAPI.GetWalkMaxSpeed(YaEntity character)

ReturnsSpeed (m/s)
Gets the current walking speed
  • character Character

void YaCharacterAPI.SetRunMaxSpeed(YaEntity character, number value)

SERVER ONLY 
Set the maximum running speed
  • character Character
  • value Max speed (m/s)

number YaCharacterAPI.GetRunMaxSpeed(YaEntity character)

ReturnsSpeed (m/s)
Get the maximum running speed
  • character Character

void YaCharacterAPI.SetJumpHeight(YaEntity character, number value)

SERVER ONLY 
Set the jump height
  • character Character
  • value Jump height

number YaCharacterAPI.GetJumpHeight(YaEntity character)

Returnsjump height
Gets the height of the current maximum jump
  • character Character

void YaCharacterAPI.SetNumberOfJump(YaEntity character, number value)

SERVER ONLY 
Set the number of consecutive jumps
  • character character
  • value Number Of Jump

number YaCharacterAPI.GetNumberOfJump(YaEntity character)

ReturnsNumber Of Jump
Gets the number of consecutive jumps
  • character character

void YaCharacterAPI.SetGravity(YaEntity character, number value)

SERVER ONLY 
Set the Character gravity value. Affects fall speed
  • character Character
  • value Gravity

number YaCharacterAPI.GetGravity(YaEntity character)

ReturnsGravity
Gets the gravity value that affects the Character
  • character Character

boolean YaCharacterAPI.Equip(YaEntity character, YaEntity entity, YaEquipParameter parameter)

SERVER ONLY 
ReturnsWhether the equipment was successful
Equip an Entity to Character
  • character Character
  • entity The entity to be equipped
  • parameter Extra parameters

boolean YaCharacterAPI.EquipTool(YaEntity character, YaEntity entity)

SERVER ONLY 
ReturnsWhether the equipment was successful
Equip a Tool Entity to Character.
  • character Character
  • entity Tool

boolean YaCharacterAPI.Unequip(YaEntity character, YaEntity entity)

SERVER ONLY 
ReturnsWhether the unequip was successful
Unload an Entity from the Character
  • character character
  • entity The entity to be unequipped

YaEntity YaCharacterAPI.GetEquipByPoint(YaEntity character, number bonePoint)

SERVER ONLY 
ReturnsEquipped entity
Returns an entity somewhere on the character.
  • character Character
  • bonePoint BonePoint

YaEntity YaCharacterAPI.GetToolByHand(YaEntity character)

SERVER ONLY 
ReturnsTool entity
Gets the tool in the Character's hand.
  • character Character

YaEntity YaCharacterAPI.GetToolByBonePoint(YaEntity character, number point)

SERVER ONLY 
ReturnsTool entity
Gets the tool on the binding point.
  • character Character entity
  • point Binding bone point

Array<YaEntity> YaCharacterAPI.GetToolsByBonePoint(YaEntity character, number point)

SERVER ONLY 
ReturnsTool list
Gets all tools on the binding point.
  • character Character entity
  • point Binding bone point

Array<YaEntity> YaCharacterAPI.GetAllTools(YaEntity character)

SERVER ONLY 
ReturnsAll tools
Gets all tools on the Character
  • character character entity