IPlayerCharacter - jimdroberts/FishMMO GitHub Wiki

Description

Interface for player-controlled character entities, extending ICharacter with player-specific properties and methods. Includes networking, instance, race, chat, hotkey, and teleportation features.


API Access

Fields

  • static Action OnReadPayload

    Event triggered when a payload is read for this player character.

  • static Action OnStartLocalClient

    Event triggered when the local client starts for this player character.

  • static Action OnStopLocalClient

    Event triggered when the local client stops for this player character.

  • static Action OnTeleport

    Event triggered when this player character teleports.

  • string CharacterName { get; set; }

    The display name of the character.

  • string CharacterNameLower { get; set; }

    Lowercase version of the character's name for case-insensitive comparisons.

  • long WorldServerID { get; set; }

    Unique identifier for the world server this character belongs to.

  • string Account { get; set; }

    The account name associated with this character.

  • DateTime TimeCreated { get; set; }

    The date and time when this character was created.

  • AccessLevel AccessLevel { get; set; }

    The access level of the player (e.g., admin, moderator, player).\n

  • string TeleporterName { get; set; }

    The name of the teleporter used for the last teleport action.

  • NetworkConnection Owner { get; }

    The network connection that owns this character.

  • NetworkObject NetworkObject { get; }

    The network object representing this character in FishNet networking.

  • PredictionManager PredictionManager { get; }

    The prediction manager for client-side prediction and reconciliation.

  • HashSet Observers { get; }

    The set of network connections observing this character.

  • int RaceID { get; set; }

    The race ID of the character.

  • int ModelIndex { get; set; }

    The model index for the character's race appearance.

  • string RaceName { get; set; }

    The name of the character's race.

  • string BindScene { get; set; }

    The name of the scene where the character is bound (e.g., respawn location).\n

  • Vector3 BindPosition { get; set; }

    The position in the bind scene where the character will respawn.

  • string SceneName { get; set; }

    The name of the current scene the character is in.

  • int SceneHandle { get; set; }

    The handle of the current scene.

  • long InstanceID { get; set; }

    Unique identifier for the instance the character is in.

  • string InstanceSceneName { get; set; }

    The name of the instance scene.

  • int InstanceSceneHandle { get; set; }

    The handle of the instance scene.

  • Vector3 InstancePosition { get; set; }

    The position in the instance scene.

  • Quaternion InstanceRotation { get; set; }

    The rotation in the instance scene.

  • KinematicCharacterMotor Motor { get; }

    The motor for kinematic character movement.

  • KCCController CharacterController { get; }

    The controller for kinematic character movement.

  • KCCPlayer KCCPlayer { get; }

    The player controller for kinematic character movement.

#if !UNITY_SERVER

  • Camera EquipmentViewCamera { get; set; }

    The camera used for equipment view (e.g., inspecting gear).\n#endif

  • string LastChatMessage { get; set; }

    The last chat message sent by the character.

  • DateTime NextChatMessageTime { get; set; }

    The next time the character is allowed to send a chat message.

  • DateTime NextInteractTime { get; set; }

    The next time the character is allowed to interact with objects.

  • List Hotkeys { get; set; }

    The list of hotkey data for this character.

Methods

  • bool IsInInstance()

    Returns true if the character is currently inside an instance.

  • void ResetHotkeys()

    Resets all hotkeys to their default state.

  • void SetGuildName(string guildName)

    Sets the guild name for this character. Parameters:

    • string guildName: The name of the guild to set.
  • void Teleport(string teleporterName)

    Teleports the character using the specified teleporter name. Parameters:

    • string teleporterName: The name of the teleporter to use.

Basic Usage

Setup

  1. Implement IPlayerCharacter for all player-controlled character types in your game.
  2. Use the interface to manage player-specific state, networking, and features.
  3. Integrate with other systems (e.g., chat, hotkeys, teleportation) via the defined properties and methods.

Example

// Example 1: Implementing IPlayerCharacter
public class PlayerCharacter : MonoBehaviour, IPlayerCharacter {
    // Implement all required properties and methods
}

// Example 2: Teleporting a player character
playerCharacter.Teleport("DungeonEntrance");

// Example 3: Resetting hotkeys
playerCharacter.ResetHotkeys();

Best Practices

  • Always implement all required properties and methods when creating a new player character type.
  • Use the provided events to hook into important player lifecycle moments.
  • Keep networking and instance data up to date for correct multiplayer behavior.
  • Use the interface for type safety and consistency across player character systems.
⚠️ **GitHub.com Fallback** ⚠️