Character

Associated namespace: sm.character

A userdata object representing a character in the game.

Values:

Functions:

Operations:

OperationDescription
Character == CharacterChecks 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.


worldPosition Vec3

Get:

Returns 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)

Applies impulse to the characters tumbling shape.

Parameters:

TypeNameDescription
CharactercharacterThe character.
Vec3impulseThe impulse.

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 animatons { { 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.

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.

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.

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.

getTumblingExtent(character)

Returns the extent of the characters tumbeling 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 tumbeling shape.

Parameters:

TypeNameDescription
CharactercharacterThe character.

Returns:

TypeDescription
Vec3The tumbling shape's world position.

getTumblingWorldRotation(character)

Returns the world rotation of the characters tumbeling 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.

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, state)

Get the character climbing state.

Parameters:

TypeNameDescription
CharactercharacterThe character.
booleanstateThe 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, state)

Get the character diving state.

Parameters:

TypeNameDescription
CharactercharacterThe character.
booleanstateThe state.

isDowned(character, state)

Get the character downed state.

Parameters:

TypeNameDescription
CharactercharacterThe character.
booleanstateThe state.

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.

isSprinting(character)

Returns whether a character is currently sprinting.

Parameters:

TypeNameDescription
CharactercharacterThe character.

Returns:

TypeDescription
booleanWhether the character is sprinting.

isSwimming(character, state)

Get the character swimming state.

Parameters:

TypeNameDescription
CharactercharacterThe character.
booleanstateThe state.

isTumbling(character, state)

Get the character tumbling state.

Parameters:

TypeNameDescription
CharactercharacterThe character.
booleanstateThe state.

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 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 state.

setDowned(character, state)

Server only

Sets whether the character is downed.

Parameters:

TypeNameDescription
CharactercharacterThe character.
booleanstateThe 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).

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, Effect)

Sets the movement effect set filepath.

Parameters:

TypeNameDescription
CharactercharacterThe character.
stringEffectset filepath The 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=nil, requiresLoS=false, renderDistance=10000, fadeDistance=9500)

Client only

Sets the name tag display value for the character

Parameters:

TypeNameDescription
CharactercharacterThe character.
stringnameThe new name tag text value.
colorcolor=nilThe color of the name. (defaults to white)
boolrequiresLoS=falseWhether broken line of sight will hide the name tag.
floatrenderDistance=10000Max distance the name tag will render in.
floatfadeDistance=9500Distance where fade out will start.

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.

Parameters:

TypeNameDescription
CharactercharacterThe character.
booleanstateThe state.

setTumbling(character, state)

Server only

Sets whether the character is tumbling.

Parameters:

TypeNameDescription
CharactercharacterThe character.
booleanstateThe state.

setUpDirection(character, up)

Client only

Sets the upward direction of the character's graphics.

Parameters:

TypeNameDescription
CharactercharacterThe character.
Vec3upThe direction.

setWorldPosition(character, The)

Server only

Sets the world position of a character.

Parameters:

TypeNameDescription
CharactercharacterThe character.
Vec3Thecharacter's new world position.

updateAnimation(character, name, time, weight=nil, additive=nil)

Client only

Updates a character animation.

Parameters:

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