NPC | CraytaKit
Skip to main content

NPC

Inherits from: CharacterBase

Functions

Function NameReturn TypeDescriptionTags
Roll()NoneTrigger a roll in the direction the NPC is moving. Will roll forwards when the NPC is stationary.Server Only
Jump(string propertyName)NoneMake the NPC jump. This may also trigger a mantle if the NPC is in a position to do so. NPC mantling works the same way as Player Character mantling.Server Only
SetCrouching(bool shouldCrouch)NoneSet the crouch state of the NPC.None
SetLookAtEntity(CharacterBase characterBase)NoneSet a CharacterBase as the look at focus for this NPC. The NPC will continuously rotate to face the target until the focus is changed or cleared. This will focus on the Head of the target CharacterBase. Only one focus may be set, this will override any previous entity or position focus. This will also override the facing of an NPC during movement, allowing for NPCs to look and move in different directions.Server Only
SetLookAtEntity(CharacterBase characterBase, string socket)NoneSet a CharacterBase as the look at focus for this NPC. The NPC will continuously rotate to face the target until the focus is changed or cleared. Use the Socket parameter to focus on a specific socket on the target. Only one focus may be set, this will override any previous entity or position focus. This will also override the facing of an NPC during movement, allowing for NPCs to look and move in different directions.Server Only
SetLookAtEntity(Entity entity)NoneSet an entity as the look at focus for this NPC. The NPC will continuously rotate to face the target until the focus is changed or cleared. Only one focus may be set, this will override any previous entity or position focus. This will also override the facing of an NPC during movement, allowing for NPCs to look and move in different directions.Server Only
GetLookAtEntity()EntityGet the entity this NPC is focused on; this will be the entity passed into SetLookAtEntity.Server Only
SetLookAtPosition(Vector position)NoneSet a world position as the look at focus for this NPC. The NPC will continuously rotate to face this position until the focus is changed or cleared. Only one focus may be set, this will override any previous entity or position focus.Server Only
GetLookAtPosition()VectorReturns the focus position of this NPC. If a focus has been manually set this will either be the value set using SetLookAtPosition, or the a position calculated from the position of the Entity set using SetLookAtEntity. Alternatively if the NPC is moving using the MoveToPosition command it will return the position the NPC is moving towards.Server Only
GetLookAt()VectorReturns two values, the position of the NPC and the position the NPC is looking at.Server Only
ClearLookAt()NoneClear the current NPC look at focus.Server Only
MoveToPosition(Vector targetPosition)NoneInstruct the NPC to move to the specified world vector. This does not utilise any pathfinding or obstacle avoidance; the NPC will move in a straight line towards the target position. It will not automatically use any special movement actions like Jump, Crouch or Mantle. The NPC will stop moving once it has reached the target position.Server Only
MoveToPosition(Vector targetPosition, number movementMode)NoneInstruct the NPC to move to the specified world vector. This does not utilise any pathfinding or obstacle avoidance; the NPC will move in a straight line towards the target position. It will not automatically use any special movement actions like Jump, Crouch or Mantle. The NPC will stop moving once it has reached the target position. This overload includes a 'MovementMode' parameter to specify the MovementMode the NPC should use. See MovementMode enum for details.Server Only
MoveToPosition(Vector targetPosition, function callback)NoneInstruct the NPC to move to the specified world vector. This does not utilise any pathfinding or obstacle avoidance; the NPC will move in a straight line towards the target position. It will not automatically use any special movement actions like Jump, Crouch or Mantle. The NPC will stop moving once it has reached the target position. The completion callback function will be called when the movement completes or is cancelled for any reason. Callback contains 1 bool parameter which will be true if the NPC successfully reached it's target; False otherwise.Server Only
MoveToPosition(Vector targetPosition, function callback, number movementMode)NoneInstruct the NPC to move to the specified world vector. This does not utilise any pathfinding or obstacle avoidance; the NPC will move in a straight line towards the target position. It will not automatically use any special movement actions like Jump, Crouch or Mantle. The NPC will stop moving once it has reached the target position. This overload includes a 'MovementMode' parameter to specify the MovementMode the NPC should use. 1 = Walk, 2 = Run, 3 = Sprint The completion callback function will be called when the movement completes or is cancelled for any reason. Callback contains 1 bool parameter which will be true if the NPC successfully reached it's target; False otherwise.Server Only
CancelMovement()NoneCancel the current NPC movementServer Only
PlayEmote(EmoteAsset emoteAsset)NonePlay the specified emote on the NPC.Server Only
IsPlayingEmote()booleanReturns true if an emote is currently playing on the NPC.Server Only
CancelEmote()NoneCancel any emote that is currently playing.Server Only

Examples

© 2024 CraytaKit