• Studio

  • Studio API

  • Bots

  • Web API

  • Designer Resources

  • Host Resources

  • Character

    Inherits from: Behaviour

    Represents an in-game character, providing properties and methods to control its movement, appearance, and interaction within the game environment.

    Properties

    isMoving

    boolean

    Indicates whether the character is currently moving.

    local player = client.localPlayer
    
    print(tostring(player.character.isMoving))
    

    Returns the distance from the character to its destination.

    local player = client.localPlayer
    
    print(player.character.distanceToDestination)
    

    The target destination of the character in the game world.

    local player = client.localPlayer
    
    player.character.destination = Vector3.New(0, 0, 0)
    

    isAnchored

    boolean

    When set to true, the character uses pathfinding to navigate to its destination.

    local player = client.localPlayer
    
    player.character.usePathfinding = true
    

    Specifies the rendering layer of the character for drawing order.

    local player = client.localPlayer
    
    player.character.renderLayer = 1
    

    The position of the character in the game world for rendering purposes.

    local player = client.localPlayer
    
    player.character.renderPosition = Vector3.New(0, 0, 0)
    

    The rotation of the character in the game world for rendering purposes.

    local player = client.localPlayer
    
    player.character.renderRotation = Quaternion.New(0, 0, 0, 1)
    

    The scale of the character in the game world for rendering purposes.

    local player = client.localPlayer
    
    player.character.renderScale = Vector3.New(1, 1, 1)
    

    Reference to the player object that controls or owns the character.

    local player = client.localPlayer
    
    print(player.character.player)
    

    An event that is triggered when the character's state changes.

    local player = client.localPlayer
    
    player.character.StateChanged:Connect(function(state)
      print("Character state changed to " .. state)
    end)
    

    An event that is triggered when the character finishes moving to a destination.

    local player = client.localPlayer
    
    player.character.MoveFinished:Connect(function()
      print("Character has finished moving.")
    end)
    

    An event that is triggered when an animation event occurs on the character.

    local player = client.localPlayer
    
    player.character.AnimationEvent:Connect(function(event)
      print("Animation event: " .. event)
    end)
    

    state

    number

    The current state of the character.

    local player = client.localPlayer
    
    print(player.character.state)
    

    speed

    number

    The movement speed of the character.

    local player = client.localPlayer
    
    player.character.speed = 10
    

    Methods

    Teleports the character to a specified position.

    local player = client.localPlayer
    
    player.character:Teleport(Vector3.New(0, 0, 0))
    

    Parameters

    Returns

    boolean

    Sets the character to an idle state.

    local player = client.localPlayer
    
    player.character:SetIdle()
    

    Returns

    void

    Plays a specified emote animation on the character.

    local player = client.localPlayer
    
    player.character:PlayEmote("idle-dance-casual")
    

    Parameters

    emoteName

    string

    The name of the emote to play.

    loop

    boolean

    Whether the emote should loop.

    callback
    LuaFunction

    A callback function to execute when the emote playback is complete.

    Returns

    void

    Moves the character to a specified position.

    local player = client.localPlayer
    
    player.character:MoveTo(Vector3.New(0, 0, 0))
    

    Parameters

    position
    Vector3

    The target position for the character to move to.

    areaMask

    number

    An optional mask to specify allowed movement areas.

    callback
    LuaFunction

    A callback function to execute when movement is complete.

    Returns

    boolean

    Returns true if movement is successfully initiated.

    Moves the character within a specified range of a position.

    local player = client.localPlayer
    
    player.character:MoveWithinRangeOf(Vector3.New(0, 0, 0), 5)
    

    Parameters

    position
    Vector3

    The target position for the character to approach.

    distance

    number

    The desired distance from the target position.

    areaMask

    number

    An optional mask to specify allowed movement areas.

    callback
    LuaFunction

    A callback function to execute when movement is complete.

    Returns

    boolean

    Returns true if movement is successfully initiated.

    Parameters

    anchor
    Anchor
    callback
    LuaFunction

    Returns

    boolean

    Parameters

    anchor
    Anchor
    distance

    number

    areaMask

    number

    callback
    LuaFunction

    Returns

    boolean

    Smoothly transitions the character's render position from one point to another.

    local player = client.localPlayer
    
    player.character:TweenRenderPosition(Vector3.New(0, 0, 0), Vector3.New(10, 0, 0))
    

    Parameters

    The starting position for the tween.

    The ending position for the tween.

    Returns

    Tween

    A Tween object representing the transition.

    Initiates a smooth transition for the character's render position to a specified destination.

    local player = client.localPlayer
    
    player.character:TweenRenderPositionTo(Vector3.New(10, 0, 0))
    

    Parameters

    The target position for the character's render position.

    Returns

    Tween

    A Tween object representing the transition.

    Sets the character's outfit to a specified asset.

    Parameters

    The outfit asset to apply to the character.

    Returns

    void

    Resets the character's outfit to its default appearance.

    Returns

    void

    Removes the character's current outfit.

    Parameters

    The outfit asset to remove from the character.

    Returns

    void

    Adds an outfit to the character's current appearance.

    Parameters

    The outfit asset to add to the character.

    Returns

    void

    Updated 2 months ago

    PocketWorlds Icon

    © 2024 Pocket Worlds. All rights reserved.