Skip to main content

Character​

Associated namespace: sm.character

A userdata object representing a character in the game.

Values:

  • clientPublicData [ table ]

    • Get: (Client-Only) The character's client public data.
    • Set: (Client-Only) Sets the character's client public data.
  • color [ color ]

    • Get: The character's color.
    • Set: (Server-Only) Sets the character's color.
  • direction [ Vec3 ]

    • Get: The character's view/aim direction.
  • smoothDirection [ Vec3 ]

    • Get: The view/aim direction, smoother in multiplayer.
  • id [ int ]

    • Get: The id of the character.
  • mass [ number ]

    • Get: The mass of the character.
  • movementSpeedFraction [ number ]

    • Get: The character's current movement speed fraction.
    • Set: (Server-Only) Sets the character's movement speed fraction.
  • publicData [ table ]

    • Get: (Server-Only) The character's server public data.
    • Set: (Server-Only) Sets the character's server public data.
  • velocity [ vec3 ]

    • Get: The velocity of the character.
  • worldPosition [ vec3 ]

    • Get: The world position of the character.

Operations:

OperationDescription
Character == CharacterChecks if two instances of Character refer to the same Character.

Functions​

addRenderable​

character:addRenderable( renderable )

Client-Only

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

Parameters:

  • character (Character): The character.
  • renderable (string): Path to the renderable file.

applyTumblingImpulse​

character:applyTumblingImpulse( impulse )

Applies an impulse to the character's tumbling shape.

Parameters:

  • character (Character): The character.
  • impulse (Vec3): The impulse.

bindAnimationCallback​

character:bindAnimationCallback( animationName, triggerTime, callback )

Binds the character's animation to a callback function.

Parameters:

  • character (Character): The character.
  • animationName (string): The name of the animation.
  • triggerTime (number): The required time that will have elapsed in the animation when the callback is triggered.
  • callback (string): The name of the Lua function to bind.

getActiveAnimations​

character:getActiveAnimations()

Returns the set of active animations.

Parameters:

Returns:

  • (table): The set of active animations.

getAnimationInfo​

character:getAnimationInfo( name )

Client-Only

[Missing Description]

Parameters:

  • character (Character): The character.
  • name (string): The name.

Returns:

  • (table): The animation info.

getCanSwim​

character:getCanSwim()

Returns whether the character will float or sink in liquid.

Parameters:

Returns:

  • (boolean): True if the character floats, false if the character sinks.

getCharacterType​

character:getCharacterType()

Returns the uuid of the character.

Parameters:

Returns:

  • (Uuid): The character's UUID.

getClientPublicData​

character:getClientPublicData()

Client-Only

Returns client public data from the character.

Parameters:

Returns:

  • (table): The character's client public data.

getColor​

character:getColor()

Returns the base color of the character.

Parameters:

Returns:

  • (Color): The character's color.

getCurrentMovementNoiseRadius​

character:getCurrentMovementNoiseRadius()

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

Parameters:

Returns:

  • (number): The character's noise radius.

getCurrentMovementSpeed​

character:getCurrentMovementSpeed()

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

Parameters:

Returns:

  • (number): The character's movement speed.

getDirection​

character:getDirection()

Returns the direction in which the character is viewing or aiming.

Parameters:

Returns:

  • (Vec3): The character's view direction.

getSmoothViewDirection​

character:getSmoothViewDirection()

Returns the direction in which the character is viewing or aiming, in a smoother
way when playing in multiplayer.

Parameters:

Returns:

  • (Vec3): The character's view direction.

getGlowMultiplier​

character:getGlowMultiplier()

Client-Only

Returns the character's glow multiplier.

Parameters:

Returns:

  • (number): The character's glow multiplier (0.0 - 1.0).

getHeight​

character:getHeight()

Returns the height of the character.

Parameters:

Returns:

  • (number): The character's height.

getId​

character:getId()

Returns the id of the character.

Parameters:

Returns:

  • (int): The character's id.

getLockingInteractable​

character:getLockingInteractable()

Returns the Interactable that the Character is locked to.

Parameters:

Returns:


getMass​

character:getMass()

Returns the mass of the character.

Parameters:

Returns:

  • (number): The character's mass.

getMovementSpeedFraction​

character:getMovementSpeedFraction()

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

Parameters:

Returns:

  • (number): The movement speed fraction.

getPlayer​

character:getPlayer()

Returns the player controlling the character.

Parameters:

Returns:

  • (Player): The character's player.

getPublicData​

character:getPublicData()

Server-Only

Returns character's server public data.

Parameters:

Returns:

  • (table): The character's server public data.

getRadius​

character:getRadius()

Returns the radius of the character.

Parameters:

Returns:

  • (number): The character's radius.

getSurfaceNormal​

character:getSurfaceNormal()

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

Parameters:

Returns:

  • (Vec3): The character's surface normal.

getTpBonePos​

character:getTpBonePos( jointName )

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

Parameters:

  • character (Character): The character.
  • jointName (string): The joint name.

Returns:

  • (Vec3): The joint position.

getTpBoneRot​

character:getTpBoneRot( jointName )

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

Parameters:

  • character (Character): The character.
  • jointName (string): The joint name.

Returns:

  • (Quat): The joint rotation.

getTumblingExtent​

character:getTumblingExtent()

Returns the extent of the characters tumbling shape.

Parameters:

Returns:

  • (Vec3): The tumbling shape's extent.

getTumblingLinearVelocity​

character:getTumblingLinearVelocity()

Returns the linear velocity of the characters tumbling shape.

Parameters:

Returns:

  • (Vec3): The tumbling shape's linear velocity.

getTumblingWorldPosition​

character:getTumblingWorldPosition()

Returns the world position of the characters tumbling shape.

Parameters:

Returns:

  • (Vec3): The tumbling shape's world position.

getTumblingWorldRotation​

character:getTumblingWorldRotation()

Returns the world rotation of the characters tumbling shape.

Parameters:

Returns:

  • (Quat): The tumbling shape's world rotation.

getUnit​

character:getUnit()

Returns the unit controlling the character.

Parameters:

Returns:

  • (Unit): The unit controlling the character.

getVelocity​

character:getVelocity()

Returns the velocity of the character.

Parameters:

Returns:

  • (Vec3): The character's velocity.

getWorld​

character:getWorld()

Returns the world the character exists in.

Parameters:

Returns:

  • (World): The character's world.

getWorldPosition​

character:getWorldPosition()

Returns the world position of the character.

Parameters:

Returns:

  • (Vec3): The character's world position.

isAiming​

character:isAiming()

Returns whether the character is currently aiming with a weapon.

Parameters:

Returns:

  • (boolean): Whether the character is aiming or not.

isClimbing​

character:isClimbing()

Returns whether the character is currently climbing.

Parameters:

Returns:

  • (boolean): Whether the character is climbing or not.

isCrouching​

character:isCrouching()

Returns whether the character is currently crouching.

Parameters:

Returns:

  • (boolean): Whether the character is crouching or not.

isDefaultColor​

character:isDefaultColor()

Returns true if the character color has its default color.

Parameters:

Returns:

  • (boolean): Whether the character has its default color.

isDiving​

character:isDiving()

Returns whether the character is currently diving.

Parameters:

Returns:

  • (boolean): Whether the character is diving or not.

isDowned​

character:isDowned()

Returns whether the character is currently downed.

Parameters:

Returns:

  • (boolean): Whether the character is downed or not.

isOnGround​

character:isOnGround()

Returns whether the character is currently standing on the ground.

Parameters:

Returns:

  • (boolean): Whether the character is on the ground or not.

isPlayer​

character:isPlayer()

Returns whether the character belongs to a player.

Parameters:

Returns:

  • (boolean): Whether the character belongs to a player or not.

isSprinting​

character:isSprinting()

Returns whether the character is currently sprinting.

Parameters:

Returns:

  • (boolean): Whether the character is sprinting or not.

isSwimming​

character:isSwimming()

Returns whether the character is currently swimming.

Parameters:

Returns:

  • (boolean): Whether the character is swimming or not.

isTumbling​

character:isTumbling()

Returns whether the character is currently tumbling.

Parameters:

Returns:

  • (boolean): Whether the character is tumbling or not.

removeAnimationCallbacks​

character:removeAnimationCallbacks()

Removes all of the character's animation callbacks.

Parameters:


removeRenderable​

character:removeRenderable( renderable )

Client-Only

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

Parameters:

  • character (Character): The character.
  • renderable (string): Path to the renderable file.

setAllowTumbleAnimations​

character:setAllowTumbleAnimations( allow )

Client-Only

Enables or disables event animations.

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

Parameters:

  • character (Character): The character.
  • allow (boolean): Whether animations are allowed or not.

setClientPublicData​

character:setClientPublicData( data )

Client-Only

Sets the character's client public data.

Parameters:

  • character (Character): The character.
  • data (table): The client public data.

setClimbing​

character:setClimbing( state )

Server-Only

Sets whether the character is climbing.

Parameters:

  • character (Character): The character.
  • state (boolean): Whether the character is climbing or not.

setColor​

character:setColor( color )

Server-Only

Sets the character's color.

Parameters:


setDiving​

character:setDiving( state )

Server-Only

Sets whether the character is diving.

Parameters:

  • character (Character): The character.
  • state (boolean): Whether the character is diving or not.

setDowned​

character:setDowned( state )

Server-Only

Sets whether the character is downed.

Parameters:

  • character (Character): The character.
  • state (boolean): Whether the character is downed or not.

setGlowMultiplier​

character:setGlowMultiplier( value )

Client-Only

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

Parameters:

  • character (Character): The character.
  • value (number): The glow multiplier (0.0 - 1.0).

setLockingInteractable​

character:setLockingInteractable( interactable )

Set the Interactable that the character is locked to.
Set it to nil to unlock.

Parameters:

Returns:

  • (boolean): Whether the locking/unlocking was successful.

setMovementEffects​

character:setMovementEffects( filepath )

Sets the movement effect set.

Parameters:

  • character (Character): The character.
  • filepath (string): The effectset file path.

setMovementSpeedFraction​

character:setMovementSpeedFraction( fraction )

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

Parameters:

  • character (Character): The character.
  • fraction (number): The movement speed fraction.

setMovementWeights​

character:setMovementWeights( lower, upper )

Client-Only

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

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

Parameters:

  • character (Character): The character.
  • lower (number): The lower weight.
  • upper (number): The upper weight.

setPublicData​

character:setPublicData( data )

Server-Only

Sets the character's server public data.

Parameters:

  • character (Character): The character.
  • data (table): The server public data.

setSwimming​

character:setSwimming( state )

Server-Only

Sets whether the character is swimming.

Parameters:

  • character (Character): The character.
  • state (boolean): Whether the character is swimming or not.

setTumbling​

character:setTumbling( state )

Server-Only

Sets whether the character is tumbling.

Parameters:

  • character (Character): The character.
  • state (boolean): Whether the character is tumbling or not.

setUpDirection​

character:setUpDirection( up )

Client-Only

Sets the upward direction of the character's graphics.

Parameters:


updateAnimation​

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

Client-Only

Updates the character animation.

Parameters:

  • character (Character): The character.
  • name (string): The animation name.
  • time (number): The time.
  • weight (number): The weight. Defaults to -1.0. (Optional)
  • additive (boolean): Whether the animation will be added to the default animation. Defaults to false. (Optional)

setNameTag​

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

Client-Only

Sets the name tag display value for the character.

Parameters:

  • character (Character): The character.
  • name (string): The name tag text.
  • color (Color): The the text color. Defaults to white.
  • requiresLoS (boolean): Whether the tag requires line of sight to be visible or not. Defaults to false.
  • renderDistance (number): The max distance the tag will be rendered in. Defaults to 10000.
  • fadeDistance (number): The distance above which the tag starts to fade out. Defaults to 9500.

setWorldPosition​

character:setWorldPosition( position )

Server-Only

Sets the world position of the character.

Parameters:

  • character (Character): The character.
  • position (Vec3): The world position.