Character | CraytaKit
Skip to main content

Character

Functions

Function NameReturn TypeDescriptionTags
Attach(Entity entityToAttach, string socketName)NoneDeprecated, see AttachToDeprecated, Server Only
GetUser()UserGet the User entity which controls this CharacterNone
SetAlive(boolean alive)NoneSet the character state to alive or deadServer Only
IsAlive()booleanGet whether a Player is alive. Return false for non-PlayerNone
GetLookAtPos()VectorGet the point the player is looking at, for an action camera this is the same as User:GetCameraLookAtPos but for orbit style cameras it will be in front of the playerServer Only, Local Only
GetLookAt()Vector, VectorReturn two values, the position of the player's virtual "eye" and the position the player is looking at. For an action camera this is the same as User:GetCameraLookAt but for an orbit style camera it will be the player's head position and what is in front of the playerServer Only, Local Only
SetInputLocked(boolean inputLocked)NoneLock player controlServer Only, Local Only
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
GetInteraction()Entity, HitResultGet whichever Entity you would interact with if you pressed interactServer Only, Local Only
PlayVibrationEffect(VibrationEffectAsset effect)NonePlays the given vibration effect on the player's controllerNone
PlayManualVibration(number intensity, number duration, boolean affectSmallMotors, boolean affectLargeMotors)Manually vibrate the player's controllerNone
AdjustAim(...)AdjustAimHandleProgrammatically move the user's camera to look at specific pointsNone
CancelAdjustAim(AdjustAimHandle handle)Cancel an aim adjustmentNone
IsAdjustAimActive()booleanReturns whether the player's aim is currently being adjustedNone

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
canRollbooleanTurn on or off ability to rollRead-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
canJumpbooleanTurn on or off ability to jumpRead-Write
displayDefaultNameTagbooleanTurn on or off the default name tagRead-Write
displayDefaultQuickChatbooleanTurn on or off the default overhead quick chatRead-Write
canCrouchbooleanTurn on or off ability to crouch or go proneRead-Write
interactionRangenumberInteraction range (from camera in cm)Read-Write
cameraTypenumberSet the character camera type. 1 = Action, 2 = OrbitRead-Write
forcedCameraPerspectivenumberSet restrictions on the action player camera perspective. 1 = No Restrictions, 2 = 1st Person Only, 3 = 3rd Person Only. (Default is 1)Read-Write
canIronSightbooleanWill the action camera iron-sight on secondary pressRead-Write
thirdPersonFOVnumberFOV of the third person action cameraRead-Write
thirdPersonIronSightFOVnumberFOV of the third person action camera in Iron Sight modeRead-Write
firstPersonFOVnumberFOV of the third person action cameraRead-Write
firstPersonIronSightFOVnumberFOV of the third person action camera in Iron Sight modeRead-Write
ironSightLookSpeedMultipliernumberSpeed multiplier of the look controls in Iron Sight modeRead-Write
cameraDistancenumberSet the orbit camera max distance from the characterRead-Write
cameraPitchnumberSet the orbit camera's pitchRead-Write
cameraYawnumberSet the orbit camera's yawRead-Write
cameraLockbooleanLock/Unlock the orbit cameraRead-Write
cameraSecondaryActionnumberSet what the secondary action does in the orbit cameraRead-Write
cameraCollisionEnabledbooleanEnable/Disable the camera's collisionRead-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

None

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)
© 2021 CraytaKit