Character

Associated namespace: sm.character

A userdata object representing a character in the game.

Values:

Functions:

Operations:

OperationReturn typeDescription
Character == CharacterbooleanChecks if two instances of Character refer to the same Character.

clientPublicData table

Get:

Client only

Returns client public data from a character.

Set:

Client only

Sets client public data on a character.


color Color

Get:

Returns the base color of a character.

Set:

Server only

Sets the character color.


direction Vec3

Get:

Returns the direction of where a character is viewing or aiming.


id integer

Get:

Returns the id of a character.


mass number

Get:

Returns the mass of a character.


movementSpeedFraction number

Get:

Gets the current fraction multiplier applied on the character's movement speed.

Set:

Sets a fraction multiplier to the character's movement speed.


publicData table

Get:

Server only

Returns (server) public data from a character.

Set:

Server only

Sets (server) public data on a character.


smoothDirection Vec3

Get:

Returns the smooth direction of where a character is viewing or aiming.


velocity Vec3

Get:

Returns the velocity of a character.


world World

Get:

Returns the world a character exists in.


worldPosition Vec3

Get:

Returns the world position of a character.

Set:

Server only

Sets the world position of a character.


addRenderable(character, renderable)

Client only

Adds a renderable (file containing model data) to be used for the character in third person view.

Parameters:

TypeNameDescription
CharactercharacterThe character.
stringrenderableThe renderable path.

applyTumblingImpulse(character, impulse, offset?)

Applies impulse to the characters tumbling shape.

Parameters:

TypeNameDescription
CharactercharacterThe character.
Vec3impulseThe impulse.
Vec3offset?The offset from the center point. (Defaults to no offset)

bindAnimationCallback(character, animationName, triggerTime, callback)

Binds a character's animation to a callback function.

Parameters:

TypeNameDescription
CharactercharacterThe character.
stringanimationNameThe name of the animation.
numbertriggerTimeThe required time that will have elapsed in the animation when the callback is triggered.
stringcallbackThe name of the Lua function to bind.

getActiveAnimations(character)

Returns the set of active animations.

Parameters:

TypeNameDescription
CharactercharacterThe character.

Returns:

TypeDescription
tableThe set of active animations { { name = string, weight = number }, ...}

getAnimationInfo(character, name)

Client only

Parameters:

TypeNameDescription
CharactercharacterThe character.
stringnameThe name.

Returns:

TypeDescription
tableThe animation info { name = string, duration = number, looping = boolean }.

getCanSwim(character)

Returns whether the character will float or sink in liquid.

Parameters:

TypeNameDescription
CharactercharacterThe character.

Returns:

TypeDescription
booleanTrue if the character will float, false if the character will sink.

getCharacterType(character)

Returns the uuid of the character.

Parameters:

TypeNameDescription
CharactercharacterThe character.

Returns:

TypeDescription
UuidThe character type.

getClientPublicData(character)

Client only

Returns client public data from a character.

Parameters:

TypeNameDescription
CharactercharacterThe character.

Returns:

TypeDescription
tableThe client public data.

getColor(character)

Returns the base color of a character.

Parameters:

TypeNameDescription
CharactercharacterThe character.

Returns:

TypeDescription
ColorThe character color.

getCurrentMovementNoiseRadius(character)

Returns the radius around the character where it can be heard.

Parameters:

TypeNameDescription
CharactercharacterThe character.

Returns:

TypeDescription
numberThe noise radius of the character.

getCurrentMovementSpeed(character)

Returns the current movement speed of the character depending on state and multiplier.

Parameters:

TypeNameDescription
CharactercharacterThe character.

Returns:

TypeDescription
numberThe current movement speed.

getDirection(character)

Returns the direction of where a character is viewing or aiming.

Parameters:

TypeNameDescription
CharactercharacterThe character.

Returns:

TypeDescription
Vec3The character's view direction.

getGlowMultiplier(character)

Client only

Gets the glow multiplier.

Parameters:

TypeNameDescription
CharactercharacterThe character.

Returns:

TypeDescription
numberThe glow multiplier (0.0 - 1.0).

getHeight(character)

Returns the height of a character

Parameters:

TypeNameDescription
CharactercharacterThe character.

Returns:

TypeDescription
numberThe character's height.

getId(character)

Returns the id of a character.

Parameters:

TypeNameDescription
CharactercharacterThe character.

Returns:

TypeDescription
integerThe character's id.

getImmovable(character)

Server only

Returns whether a non-player character is immovable,

Parameters:

TypeNameDescription
CharactercharacterThe character.

Returns:

TypeDescription
booleanThe immovable state of the character.

getJumpSpeedFraction(character)

Gets the current fraction multiplier applied on the character's jump speed.

Parameters:

TypeNameDescription
CharactercharacterThe character.

Returns:

TypeDescription
numberThe jump speed fraction.

getLockingHarvestable(character)

Get the Harvestable that the Character is locked to.

Parameters:

TypeNameDescription
CharactercharacterThe character.

Returns:

TypeDescription
HarvestableThe harvestable.

getLockingInteractable(character)

Get the Interactable that the Character is locked to.

Parameters:

TypeNameDescription
CharactercharacterThe character.

Returns:

TypeDescription
InteractableThe interactable.

getMass(character)

Returns the mass of a character.

Parameters:

TypeNameDescription
CharactercharacterThe character.

Returns:

TypeDescription
numberThe character's mass.

getMoveSpeed(character)

Returns the move speed of a character

Parameters:

TypeNameDescription
CharactercharacterThe character.

Returns:

TypeDescription
numberThe character's move speed.

getMovementSpeedFraction(character)

Gets the current fraction multiplier applied on the character's movement speed.

Parameters:

TypeNameDescription
CharactercharacterThe character.

Returns:

TypeDescription
numberThe movement speed fraction.

getPlayer(character)

Returns the player controlling the character.

Parameters:

TypeNameDescription
CharactercharacterThe character.

Returns:

TypeDescription
PlayerThe player controlling the character.

getPublicData(character)

Server only

Returns (server) public data from a character.

Parameters:

TypeNameDescription
CharactercharacterThe character.

Returns:

TypeDescription
tableThe public data.

getRadius(character)

Returns the radius of a character

Parameters:

TypeNameDescription
CharactercharacterThe character.

Returns:

TypeDescription
numberThe character's radius.

getSmoothViewDirection(character)

Returns the smooth direction of where a character is viewing or aiming.

Parameters:

TypeNameDescription
CharactercharacterThe character.

Returns:

TypeDescription
Vec3The character's smooth view direction.

getSprintSpeed(character)

Returns the sprint speed of a character

Parameters:

TypeNameDescription
CharactercharacterThe character.

Returns:

TypeDescription
numberThe character's sprint speed.

getSurfaceNormal(character)

Returns the normal of the character's contact with a surface. Defaults to a zero vector when no contact is found.

Parameters:

TypeNameDescription
CharactercharacterThe character.

Returns:

TypeDescription
Vec3The surface normal.

getTpBonePos(character, jointName)

Returns the world position for a bone in the third person view animation skeleton.

Parameters:

TypeNameDescription
CharactercharacterThe character.
stringjointNameThe joint name.

Returns:

TypeDescription
Vec3The joint position.

getTpBoneRot(character, jointName)

Returns the world rotation for a bone in the third person view animation skeleton.

Parameters:

TypeNameDescription
CharactercharacterThe character.
stringjointNameThe joint name.

Returns:

TypeDescription
QuatThe joint rotation.

getTumblingAngularVelocity(character)

Returns the angular velocity of the characters tumbling shape.

Parameters:

TypeNameDescription
CharactercharacterThe character.

Returns:

TypeDescription
Vec3The tumbling shape's angular velocity.

getTumblingExtent(character)

Returns the extent of the characters tumbling shape.

Parameters:

TypeNameDescription
CharactercharacterThe character.

Returns:

TypeDescription
Vec3The tumbling shape's extent.

getTumblingLinearVelocity(character)

Returns the linear velocity of the characters tumbling shape.

Parameters:

TypeNameDescription
CharactercharacterThe character.

Returns:

TypeDescription
Vec3The tumbling shape's linear velocity.

getTumblingWorldPosition(character)

Returns the world position of the characters tumbling shape.

Parameters:

TypeNameDescription
CharactercharacterThe character.

Returns:

TypeDescription
Vec3The tumbling shape's world position.

getTumblingWorldRotation(character)

Returns the world rotation of the characters tumbling shape.

Parameters:

TypeNameDescription
CharactercharacterThe character.

Returns:

TypeDescription
QuatThe tumbling shape's world rotation.

getUnit(character)

Returns the unit controlling the character.

Parameters:

TypeNameDescription
CharactercharacterThe character.

Returns:

TypeDescription
UnitThe unit controlling the character.

getVelocity(character)

Returns the velocity of a character.

Parameters:

TypeNameDescription
CharactercharacterThe character.

Returns:

TypeDescription
Vec3The character's velocity.

getWorld(character)

Returns the world a character exists in.

Parameters:

TypeNameDescription
CharactercharacterThe character.

Returns:

TypeDescription
WorldThe world the character exists in.

getWorldPosition(character)

Returns the world position of a character.

Parameters:

TypeNameDescription
CharactercharacterThe character.

Returns:

TypeDescription
Vec3The character's world position.

hasActiveOverrideAnimation(player)

Client only

Returns whether or not the character has an active animation override on its third person animations.

A third person animation override could be the crowbar animation when picking something up or the hammer when placing something.

Parameters:

TypeNameDescription
CharacterplayerThe player.

Returns:

TypeDescription
boolHas active animation override.

hasGraphics(character)

Client only

Checks if a character has graphics.

Parameters:

TypeNameDescription
CharactercharacterThe character.

Returns:

TypeDescription
booleanWhether the character has graphics.

isAiming(character)

Returns whether a character is currently aiming with a weapon.

Parameters:

TypeNameDescription
CharactercharacterThe character.

Returns:

TypeDescription
booleanWhether the character is aiming.

isClimbing(character)

Get the character climbing state.

Parameters:

TypeNameDescription
CharactercharacterThe character.

Returns:

TypeDescription
booleanThe climbing state.

isCrouching(character)

Returns whether a character is currently crouching.

Parameters:

TypeNameDescription
CharactercharacterThe character.

Returns:

TypeDescription
booleanWhether the character is crouching.

isDefaultColor(character)

Returns true if the current character color is its default color.

Parameters:

TypeNameDescription
CharactercharacterThe character.

Returns:

TypeDescription
booleanTrue if the color is the base color.

isDiving(character)

Get the character diving state.

Parameters:

TypeNameDescription
CharactercharacterThe character.

Returns:

TypeDescription
booleanThe diving state.

isDowned(character)

Get the character downed state.

Parameters:

TypeNameDescription
CharactercharacterThe character.

Returns:

TypeDescription
booleanThe downed state.

isFlying(character)

Get the character flying state.

Parameters:

TypeNameDescription
CharactercharacterThe character.

Returns:

TypeDescription
booleanThe flying state.

isHovering(character)

Get the character hovering state.

Parameters:

TypeNameDescription
CharactercharacterThe character.

Returns:

TypeDescription
booleanThe hovering state.

isLadderClimbing(character)

Get whether the character is climbing a ladder.

Parameters:

TypeNameDescription
CharactercharacterThe character.

Returns:

TypeDescription
booleanThe ladder climbing state.

isMoving(character)

Returns whether a character is currently moving.

Parameters:

TypeNameDescription
CharactercharacterThe character.

Returns:

TypeDescription
booleanWhether the character is moving.

isOnGround(character)

Returns whether the character is currently standing on the ground.

Parameters:

TypeNameDescription
CharactercharacterThe character.

Returns:

TypeDescription
booleanWhether the character is on the ground.

isPlayer(character)

Returns whether a character is owned by a player.

Parameters:

TypeNameDescription
CharactercharacterThe character.

Returns:

TypeDescription
booleanWhether the character is owned by a player.

isSeated(character)

Returns whether the character is currently seated.

Parameters:

TypeNameDescription
CharactercharacterThe character.

Returns:

TypeDescription
booleanWhether the character is seated.

isSprinting(character)

Returns whether a character is currently sprinting.

Parameters:

TypeNameDescription
CharactercharacterThe character.

Returns:

TypeDescription
booleanWhether the character is sprinting.

isSwimming(character)

Get the character swimming state.

Parameters:

TypeNameDescription
CharactercharacterThe character.

Returns:

TypeDescription
booleanThe swimming state.

isTumbling(character)

Get the character tumbling state.

Parameters:

TypeNameDescription
CharactercharacterThe character.

Returns:

TypeDescription
booleanThe tumbling state.

isVisible(character)

Client only

Returns whether a character is visible.

Parameters:

TypeNameDescription
CharactercharacterThe character.

Returns:

TypeDescription
booleanWhether the character is visible.

overrideRenderableList(character, renderables)

Client only

Overrides a non player character's third person renderable list with a new list of renderables. Will trigger a rebuild of the character's graphics.

Parameters:

TypeNameDescription
CharactercharacterThe character.
tablerenderablesAn array of renderable file paths to override with.

removeAnimationCallbacks(character)

Removes all of a character's animation callbacks.

Parameters:

TypeNameDescription
CharactercharacterThe character.

removeRenderable(character, renderable)

Client only

Removes a renderable (file containing model data) that was used for the character in third person view.

Parameters:

TypeNameDescription
CharactercharacterThe character.
stringrenderableThe renderable path.

setAllowTumbleAnimations(character, allow)

Client only

Enables or disables event animations.

When set to false no animations can play while tumble is active, and when set to true the animations will play while tumbling.

Parameters:

TypeNameDescription
CharactercharacterThe character.
booleanallowThe state.

setClientPublicData(character, data)

Client only

Sets client public data on a character.

Parameters:

TypeNameDescription
CharactercharacterThe character.
tabledataThe client public data.

setClimbing(character, state)

Server only

Sets whether the character is climbing.

Parameters:

TypeNameDescription
CharactercharacterThe character.
booleanstateThe climbing state.

setColor(character, color)

Server only

Sets the character color.

Parameters:

TypeNameDescription
CharactercharacterThe character.
ColorcolorThe character color.

setDiving(character, state)

Server only

Sets whether the character is diving.

Parameters:

TypeNameDescription
CharactercharacterThe character.
booleanstateThe diving state.

setDowned(character, state)

Server only

Sets whether the character is downed.

Parameters:

TypeNameDescription
CharactercharacterThe character.
booleanstateThe downed state.

setFlying(character, state)

Server only

Sets whether the character is flying.

Will not activate flight for player characters.

Parameters:

TypeNameDescription
CharactercharacterThe character.
booleanstateThe flying state.

setGlowMultiplier(character, value)

Client only

Sets a value to multiply the glow from asg texture with.

Parameters:

TypeNameDescription
CharactercharacterThe character.
numbervalueThe glow multiplier (0.0 - 1.0).

setHovering(character, state)

Server only

Sets whether the character is hovering.

Will not activate hover for player characters.

Parameters:

TypeNameDescription
CharactercharacterThe character.
booleanstateThe hovering state.

setImmovable(character, enable)

Server only

Sets the immovable state on a non-player character. This prevents the character from updating its physics.

Parameters:

TypeNameDescription
CharactercharacterThe character.
booleanenableSet immovable state.

setJumpSpeedFraction(character, fraction)

Sets a fraction multiplier to the character's jump speed.

Parameters:

TypeNameDescription
CharactercharacterThe character.
numberfractionThe jump speed fraction.

setLockingHarvestable(character, harvestable)

Set the Harvestable that the Character is locked to. Set Harvestable to nil to unlock.

Parameters:

TypeNameDescription
CharactercharacterThe character.
HarvestableharvestableThe harvestable.

Returns:

TypeDescription
booleanTrue if the character was successfully locked or unlocked.

setLockingInteractable(character, interactable)

Set the Interactable that the Character is locked to. Set Interactable to nil to unlock.

Parameters:

TypeNameDescription
CharactercharacterThe character.
InteractableinteractableThe interactable.

Returns:

TypeDescription
booleanTrue if the character was successfully locked or unlocked.

setMovementEffects(character, filepath)

Sets the movement effect set filepath.

Parameters:

TypeNameDescription
CharactercharacterThe character.
stringfilepathThe effect set filepath.

setMovementSpeedFraction(character, fraction)

Sets a fraction multiplier to the character's movement speed.

Parameters:

TypeNameDescription
CharactercharacterThe character.
numberfractionThe movement speed fraction.

setMovementWeights(character, lower, upper)

Client only

Sets the weights for movement animations on a character's upper and lower body.

For a value of 0 no movement animations will play, and for a value of 1 the movement animations will fully play unless otherwise overridden.

Parameters:

TypeNameDescription
CharactercharacterThe character.
numberlowerThe lower weight.
numberupperThe upper weight.

setNameTag(character, name, color?, requiresLoS?, renderDistance?, fadeDistance?)

Client only

Sets the name tag display value for the character

Parameters:

TypeNameDescription
CharactercharacterThe character.
stringnameThe new name tag text value.
Colorcolor?The color of the name. (defaults to white)
booleanrequiresLoS?Whether broken line of sight will hide the name tag. (Defaults to false)
numberrenderDistance?Max distance the name tag will render in. (Defaults to 10000)
numberfadeDistance?Distance where fade out will start. (Defaults to 9500)

setPublicData(character, data)

Server only

Sets (server) public data on a character.

Parameters:

TypeNameDescription
CharactercharacterThe character.
tabledataThe public data.

setSwimming(character, state)

Server only

Sets whether the character is swimming.

Note:

By default the swimming state is controlled by the client as part of the player movement. This value is treated like an override that is synchronized from the server. Buoyancy calculations in the character controller require that the character touches a liquid volume.

Parameters:

TypeNameDescription
CharactercharacterThe character.
booleanstateThe swimming state.

setTumbling(character, state)

Server only

Sets whether the character is tumbling.

Parameters:

TypeNameDescription
CharactercharacterThe character.
booleanstateThe tumbling state.

setUpDirection(character, up)

Client only

Sets the upward direction of the character's graphics.

Parameters:

TypeNameDescription
CharactercharacterThe character.
Vec3upThe direction.

setVisible(character, visible)

Client only

Sets the visibility.

Parameters:

TypeNameDescription
CharactercharacterThe character.
booleanvisibleWhether the character should be visible.

setWorldPosition(character, position)

Server only

Sets the world position of a character.

Parameters:

TypeNameDescription
CharactercharacterThe character.
Vec3positionThe character's new world position.

updateAnimation(character, name, time, weight?, additive?)

Client only

Updates a character animation.

Parameters:

TypeNameDescription
CharactercharacterThe character.
stringnameThe animation name.
numbertimeThe time.
numberweight?The weight. Defaults to -1.0. (Optional)
booleanadditive?Whether the animation will be added to the default animation. Defaults to false. (Optional)