CharacterBase | CraytaKit
Skip to main content

CharacterBase

Inherits from: Entity

Functions

Function NameReturn TypeDescriptionTags
Attach(Entity entityToAttach, string socketName)NoneDeprecated, see AttachToDeprecated, Server Only
SetAlive(boolean alive)NoneSet the character state to alive or deadServer Only
IsAlive()booleanGet whether a Player is alive. Return false for non-PlayerNone
SetGrip(GripAsset gripAsset)NoneSet the current grip animations used by this player. Passing nil is the same as calling SetNoGrip()None
SetNoGrip()NoneReverts the player back to the default 'unarmed' animations. Can also be achieved by calling SetGrip(nil)None
PlayAction(string action, table properties)NonePlay an animation action, with properties specifying how it should be playedNone
PlayAction(string action)NonePlay an animation action with default propertiesNone
HasAction(string action)booleanReturns true if the current grip can perform this type of actionNone
GetActions()tableGet the name of every available action for the current gripNone
GetActionEvents(string action)tableGet the name of every available event for an actionNone
HasActionEvent(string action, string event)booleanReturns true if this action has an animation event of the specified nameNone
GetPlayLength(string action)numberReturns the length of an animation, in seconds, assuming a playbackSpeed of 1 is setNone
Launch(Vector vector)NoneLaunch the characterNone
AdjustAim(...)AdjustAimHandleProgrammatically move the user's camera to look at specific pointsNone
CancelAdjustAim(AdjustAimHandle handle)NoneCancel an aim adjustmentNone
IsAdjustAimActive()booleanReturns whether the player's aim is currently being adjustedNone
IsCrouchingbooleanReturns true if the character is crouchingNone
StartOccupy(Entity entityToOccupy)NoneOccupying an entity will attach the character to it using animations associated with the occupy asset (sit, lie down, etc). If this entity has any occupy sockets, the character will be attached to the first socket using the occupy asset associated with this. Otherwise the character will attach to the entity position, and the default OccupyAsset (Seat) will be usedServer Only
StartOccupy(Entity entityToOccupy, string socketName)NoneOccupying an entity will attach the character to it using animations associated with the occupy asset (sit, lie down, etc). Attach the character to the provided socket. If this socket is an occupy socket, the character will occupy it using the OccupyAsset associated with this socket. Otherwise the default OccupyAsset (Seat) will be usedServer Only
StartOccupy(Entity entityToOccupy, OccupyAsset occupyAsset, string socketName)NoneOccupying an entity will attach the character to it using animations associated with the occupy asset (sit, lie down, etc). Attach the character to this socket using the animations from the Occupy AssetServer Only
StartOccupy(Entity entityToOccupy, OccupyAsset occupyAsset)NoneServer Only
EndOccupy()NoneDetaches a character from the entity it was occupying from a previous StartOccupyServer Only
IsOccupying()booleanCheck if this character is currently occupying an entityNone

Properties

Property NameReturn TypeDescriptionTags
speedMultipliernumberMultiplier on movement speed (default is 1.0)Read-Write
jumpHeightMultipliernumberMultiplier on jump height (default is 1.0)Read-Write
canSprintbooleanTurn on or off ability to sprintRead-Write
canRunbooleanTurn on or off ability to runRead-Write
canWalkbooleanTurn on or off ability to walkRead-Write
canMantlebooleanTurn on or off ability to mantleRead-Write
maxMantleHeightbooleanSet the maximum height that a player can mantleRead-Write
canSlidebooleanTurn on or off ability to slideRead-Write
canRelaxbooleanTurn on or off ability to go into a grip's relaxed poseRead-Write
breakFallbooleanTurn on or off ability to break fall on landingRead-Write
breakFallSpeedbooleanTurn on or off ability to break fall on landingRead-Write
damageEnabledbooleanTurn on or off damage (ie calling of entry point OnDamaged)Read-Write

Examples

AdjustAim

AdjustAim works in much the same way as timelines. It accepts any number of arguments, where the first argument is speed, the second argument is either a relative rotation, or a vector to look at, and the third parameter is easing.

Possible easing values are "Linear" (default), "EaseIn", and "EaseInOut".

function ExampleScript:LookAtStuff(player)
player:AdjustAim(
10, Vector.New(100, 100, 100) -- look at point (100, 100, 100) with speed 10,
100, Rotation.New(360, 0, 0), "EaseOut", -- Rotate 360 degrees with a speed of 100, easing out of the last position
1000, Vector.New(0,0,0), "EaseIn", -- Look at point (0, 0, 0) with a speed of 1000, easing in as the adjustment finished
)
end

PlayAction

The second argument for PlayAction is a table of properties.

NameTypeDescription
playbackSpeednumberSets the speed to play this animation at. 2 = double speed, 0.5 = half speed
playbackTimenumberSets the time that this animation should take in seconds
eventstableSome actions trigger events – these are functions that will be triggered in your Lua code once the animation for an action reaches a certain point

Grips

Cuff
Actions
ActionEventBranchingDescription
FireNoneNoneThis will perform a 'interacting' animation with the cuff screen
FireIsCompletedYesIf false, the player will start another cycle of interacting with the screen. If true, then the animation will end.
FireOnCompletedNoTriggers at the end of the animation (after IsCompleted returns true if the event is defined).
Example
local animData = {}
animData.playbackSpeed = 1.0
animData.events =
{
IsCompleted = function ()
Print("Checking if player is still looking at a menu")
return not self.inMenu
end,
OnCompleted = function ()
Print("Finished interacting with menu")
end
}
self:GetEntity():PlayAction("Fire", animData)
Unarmed
Actions

None

Knife
Events
ActionEventBranchingDescription
MeleeNoneNoneThis will perform a ‘slashing’ animation
MeleeMeleeImpactNoThis will trigger at the point in the animation when the knife looks like it should hit its target
Pistol
Actions
ActionEventBranchingDescription
FireNoneNoneThis will perform a ‘shooting’ animation
ReloadNoneNoneThis will perform a ‘reload’ animation
ReloadAmmoAddedNoThis will trigger at the point in the animation when the pistol clip has been inserted into the pistol
MeleeNoneNoneThis will perform a ‘pistol whip’ animation
MeleeMeleeImpactNoThis will trigger at the point in the animation when the pistol looks like it should hit its target
Rifle
Actions
ActionEventBranchingDescription
FireNoneNoneThis will perform a ‘shooting’ animation
RelaodNoneNoneThis will perform a ‘reload’ animation
ReloadAmmoAddedNoThis will trigger at the point in the animation when the clip has been inserted into the pistol
RPG
Actions
ActionEventBranchingDescription
FireNoneNoneThis will perform a ‘rocket launch’ animation
ReloadNoneNoneThis will perform a ‘reload’ animation
ReloadAmmoAddedNoThis will trigger at the point in the animation when the rocket has been inserted into the RPG
Shotgun
Actions
ActionEventBranchingDescription
FireNoneNoneThis will perform a ‘shooting’ animation
ReloadNoneNoneThis will perform a ‘reload’ animation
ReloadAmmoAddedNoThis will trigger at the point in the animation when a shell has been inserted into the shotgun
ReloadIsReloadCompleteYesIf false, another shell will be inserted into the barrel without playing the intro of the animation again. If true, the reload animation will play its outro sequence and complete
Example
local animData = {}
animData.playbackSpeed = 2.0
animData.events =
{
IsReloadComplete = function ()
Print("Checking if full")
return self.bullets == self.properties.maxBullets
end,
AmmoAdded = function ()
self.bullets = self.bullets + 1
Print("Added Bullets, current ammo = " .. self.bullets )
end
}
self:GetEntity():PlayAction("Reload", animData)
© 2024 CraytaKit