Class Player

The player object represents a client connected to your Airship game server (or a bot player if spawned).

Properties

character: undefined | Character

The player controls this entity.

clientTransferData: unknown

The client transfer data provided with the request that transferred the player to this server. This is available on both the client and the server, but is not available to non-local clients.

connectionId: number

Unique network connection ID for the player in the given server. This ID is typically given to network requests as a way to identify the player to/from the server.

This is not a unique identifier for the player outside of the server and will not persist. For a completely unique ID, use userId.

onChangeTeam: Signal<[team: Team, oldTeam: Team]> = ...

Fired on both client and server when player changes team.

onCharacterChanged: Signal<undefined | Character> = ...

Fired when the player's character changes.

onLeave: Signal<void> = ...

Fired when the player disconnects from the server. Connections will automatically be disconnected when the player leaves.

orgRoleName: undefined | string

The name of the role in the game's organization. This will be undefined if they are not a member of the organization.

platform: AirshipPlatform = ...

WARNING: not implemented yet. only returns local platform for now.

profileImageId: string

Image id used to fetch player's profile picture.

selectedOutfit: undefined | SelectedOutfit

The player's selected outfit.

OutfitDto's can be passed to Character.LoadUserOutfit()

serverTransferData: unknown

The server only transfer data provided with the request that transfered the player to this server. This is not available on the client.

team: undefined | Team

The player's current team.

You can add players to teams by using team.AddPlayer(player)

Use Airship.Teams to get references to a team.

userId: string

The player's unique ID. This is unique and unchanging per player.

String length is <= 128 characters (but will likely be far shorter -- typically 28 characters).

username: string

The player's username. This should be used for display. Username can change, so to save a player's data use userId.

voiceChatAudioSource: AudioSource

Audio source for player's voice chat. Attached to a Game Object that can be reparented to control voice chat position. By default this lives under the player's character and is muted for the local player.

Methods

  • IsConnected will return true until a player disconnects from the server.

    Returns boolean

  • Allows the server to perform a lag compensated check against the clients view of the world at the current server tick.

    Type Parameters

    • CheckResult

    Parameters

    • checkFunc: (() => CheckResult)

      This function should be used to perform read only checks against the clients view of the world. For example, perform a raycast to check if the player actually hit another player.

    • completeFunc: ((checkResult) => void)

      This function should be used to perform actions based on the result of your check and will run against the current real view of the world as the server sees it. Use this function to apply damage or move the player.

        • (checkResult): void
        • Parameters

          Returns void

    Returns void

    Returns immediately after scheduling the lag compensation check. The check and complete functions will be called later.

  • Sends player a message in chat. If called from client this won't work on non-local players.

    Parameters

    • message: string

      Message to send in chat.

    Returns void

  • Can yield if the player's outfit hasn't finished downloading.

    Parameters

    • position: Vector3

      Spawn position of character

    • Optional config: {
          customCharacterTemplate?: GameObject;
          lookDirection?: Vector3;
      }
      • Optional customCharacterTemplate?: GameObject
      • Optional lookDirection?: Vector3

        Initial facing direction of character

    Returns Character

  • Wait for a character for this given player

    Returns Character

    Yields

    Will yield the executing thread if a character does not yet exist on this player