YaCharacterAPI¶
YaCharacterAPI
manages 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 functiontarget
The target Character to be pushedtrigger
The entity that pushes the Characterdirection
The direction in which the Character is pusheddistance
The distance at which the Character is pushed
void YaCharacterAPI.OnFall(function callback<YaEntity, number>)¶
SERVER ONLY
Fired when the Character falls
callback
Callback functiontarget
The target Character to fallfall height
Fall height
void YaCharacterAPI.OnGround(function callback<YaEntity, number>)¶
SERVER ONLY
Fired when the Character lands on the ground
callback
Callback functiontarget
The target Character landing on the groundfall height
Fall height
void YaCharacterAPI.OnStartSwim(function callback<YaEntity>)¶
SERVER ONLY
Fired when the character starts swimming
callback
Callback functiontarget
The target Character that starts swimming
void YaCharacterAPI.OnEndSwim(function callback<YaEntity>)¶
SERVER ONLY
Fired when the character stops swimming
callback
Callback functiontarget
The target Character that stops swimming
void YaCharacterAPI.OnEnterHit(YaEntity character, function callback<YaEntity, number, float3>)¶
Character hit enter
character
charactercallback
Callback functionhitEntity
Hit entitysite
The site of contact 0:side 1:Up -1:Downnormal
The normal direction of the contact point
void YaCharacterAPI.OnExitHit(YaEntity character, function callback<YaEntity>)¶
Character hit exit
character
Charactercallback
Callback functionhitEntity
Hit entity
void YaCharacterAPI.OnPush(YaEntity character, function callback<YaEntity, float3, number>)¶
Current character be pushed event
character
Charactercallback
Callback functionpusher
The entity that pushes the Characterdirection
The direction in which the Character is pusheddistance
The distance at which the Character is pushed
void YaCharacterAPI.OnFall(YaEntity character, function callback<number>)¶
Current character fall event
character
Charactercallback
Callback functionfallHeight
Fall height
void YaCharacterAPI.OnGround(YaEntity character, function callback<number>)¶
The current character landing event
character
Charactercallback
Callback functionfallHeight
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)¶
Set the maximum walking speed
character
Charactervalue
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)¶
Set the maximum running speed
character
Charactervalue
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)¶
Set the jump height
character
Charactervalue
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)¶
Set the number of consecutive jumps
character
charactervalue
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)¶
Set the Character gravity value. Affects fall speed
character
Charactervalue
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)¶
ReturnsWhether the equipment was successful
Equip an Entity to Character.
character
Characterentity
The entity to be equippedparameter
Extra parameters
boolean YaCharacterAPI.EquipTool(YaEntity character, YaEntity entity)¶
ReturnsWhether the equipment was successful
Equip a Tool Entity to Character.
character
Characterentity
Tool
boolean YaCharacterAPI.Unequip(YaEntity character, YaEntity entity)¶
ReturnsWhether the unequip was successful
Unload an Entity from the Character
character
characterentity
The entity to be unequipped
YaEntity YaCharacterAPI.GetEquipByPoint(YaEntity character, number bonePoint)¶
ReturnsEquipped entity
Returns an entity somewhere on the character.
character
CharacterbonePoint
BonePoint
YaEntity YaCharacterAPI.GetToolByHand(YaEntity character)¶
ReturnsTool entity
Gets the tool in the Character's hand.
character
Character
YaEntity YaCharacterAPI.GetToolByBonePoint(YaEntity character, number point)¶
ReturnsTool entity
Gets the tool on the binding point.
character
Character entitypoint
Binding bone point
Array<YaEntity> YaCharacterAPI.GetToolsByBonePoint(YaEntity character, number point)¶
ReturnsTool list
Gets all tools on the binding point.
character
Character entitypoint
Binding bone point
Array<YaEntity> YaCharacterAPI.GetAllTools(YaEntity character)¶
ReturnsAll tools
Gets all tools on the Character
character
Character entity