Class Character

A character is a (typically human) object in the scene. It controls movement and default animation. Typically a game would spawn a character for each player. If using the default character it would be dressed with their customized outfit.

To spawn a character use Player.SpawnCharacter. To control your game's default character see CharacterConfigSetup.

Hierarchy (view full)

Constructors

  • Use Awake instead of overloading the constructor!

    • You can specify non-optional properties using the null-assertion operator - !
    export default class ExampleBehaviour extends AirshipBehaviour {
    textComponent!: TMP_Text;
    Awake() {
    this.textComponent = this.gameObject.GetComponent<TMP_Text>();
    }
    }

    Returns Character

    Deprecated

Properties

OnAddCustomInputData: Signal<[commandNumber: number]> = ...

Signals when a new input command is begin generated. Use AddCustomInputData() to add custom data to the command being generated.

This signal does not fire for observers.

OnAddCustomSnapshotData: Signal<[]> = ...

Signals when a new snapshot of the current movement state is being generated. Use AddCustomStateData() to add custom data to the snapshot being generated.

This signal does not fire for observers.

OnCompareSnapshots: Signal<[Map<string, unknown>, CharacterSnapshotData, Map<string, unknown>, CharacterSnapshotData]> = ...

Signals that two snapshots are being compared. Use SetComparisonResult() in this signals callbacks to modify the result of the comparison.

This signal only fires when the local client needs to compare it's predicted state (first parameter), to the server's authoritative state (second parameter).

OnInterpolateReachedSnapshot: Signal<[Map<string, unknown>, CharacterSnapshotData]> = ...

Signals that the movement system is displaying a character that has just reached the snapshot provided. This fires during fixed update, but may not fire every fixed update. This only fires for characters being observed. Will fire on the server for client authoritative characters.

OnInterpolateSnapshot: Signal<[Map<string, unknown>, CharacterSnapshotData, Map<string, unknown>, CharacterSnapshotData, number]> = ...

Signals that the movement system is displaying a character interpolating between the two provided snapshots. This signal is fired every frame. This only fires for characters being observed. Does not fire on the server, but may in the future.

OnResetToSnapshot: Signal<[Map<string, unknown>, CharacterSnapshotData]> = ...

Signals that the movement system is being reset to a past snapshot. This will happen during re-simulation on clients, and during lag compensation on the server. This signal will fire for an observed character if the local client is replaying.

OnUseCustomInputData: Signal<[Map<string, unknown>, CharacterInputData, boolean]> = ...

Allows you to process custom move data attached to character input before the move function is executed.

This signal does not fire for observers.

OnUseCustomInputDataAfterMove: Signal<[Map<string, unknown>, CharacterInputData, boolean]> = ...

Allows you to process custom move data attached to character input after the move function is executed.

This signal does not fire for observers.

PreCreateCommand: Signal<[commandNumber: number]> = ...

Fires before a new command is created on the client. Use this signal to create anything that will need to connect to OnAddCustomInputData for the tick about to be processed. Only fires for the local character.

PreProcessCommand: Signal<[Map<string, unknown>, CharacterInputData, boolean]> = ...

Fires before command processing.

This signal does not fire for observers.

bin: Bin = ...

A bin that is cleaned when the entity despawns.

gameObject: GameObject

The GameObject this behaviour is attached to.

inventory: default

Can be undefined if the Inventory component is removed from Character prefab.

onBeforeLocalHeldSlotChanged: Signal<BeforeLocalInventoryHeldSlotChanged> = ...

Used to cancel changing held item slots.

transform: Transform

The Transform this behaviour is attached to.

Accessors

  • get enabled(): boolean
  • The enabled state of this component

    Returns boolean

Methods

  • Add custom data to the move data command stream.

    Parameters

    • key: string
    • value: unknown

    Returns void

  • Cancels emote if the character is emoting. Otherwise, does nothing.

    Returns void

  • Despawns this character.

    SERVER ONLY METHOD

    Returns void

  • Frame-rate independent AirshipBehaviour.FixedUpdate message for physics calculations.

    Parameters

    • dt: number

    Returns void

  • Used to check if the character is owned by the Game.localPlayer

    Must be called after the character has finished initializing. You can use () to wait for initialized.

    Returns boolean

    true if the character is owned by the Game.localPlayer

  • Destroying the attached Behaviour will result in the game or Scene receiving OnDestroy.

    Returns void

  • Sets a characters health to a certain value. If the health is <= 0, the character will die.

    Parameters

    • health: number

      The new health value.

    • Optional dontInflictDeath: boolean

      If true, a death event will not be fired if the character's new health is less than or equal to zero. This is useful when you want to broadcast a custom death event with Airship.Damage.BroadcastDeath.

    • noNetwork: boolean = false

    Returns void

  • Sets the held slot on the character. Can be set for non-local players, but will be overwritten when a new update is recieved.

    Parameters

    • slot: number

    Returns void

  • Allows the use of signal based networking event if desired even if state based networking for held items is unavailable.

    Returns void

  • OnStart is called on the frame when a script is enabled just before any of the Update methods are called the first time.

    Returns void

  • This can be called from the server or from the player that owns the character and has authority

    Parameters

    • pos: Vector3
    • Optional lookVector: Vector3

    Returns void

  • Update is called every frame, if the AirshipBehaviour is enabled.

    Parameters

    • dt: number

    Returns void

  • Yields thread until the character has been initialized.

    Returns void