Class BaseCharacter
Abstract base class for all networked character entities in the game. Provides core properties, behaviour registration, flag management, and prefab/model instantiation.
[RequireComponent(typeof(NetworkObject))]
[RequireComponent(typeof(NetworkTransformDistanceLod))]
public abstract class BaseCharacter : NetworkBehaviour, ICharacter
- Inheritance
-
ObjectComponentBehaviourMonoBehaviourNetworkBehaviourBaseCharacter
- Implements
- Derived
- Inherited Members
-
NetworkBehaviour.IsSpawnedNetworkBehaviour.ComponentIndexNetworkBehaviour.NetworkObjectNetworkBehaviour.MAXIMUM_NETWORKBEHAVIOURSNetworkBehaviour.UNSET_NETWORKBEHAVIOUR_IDNetworkBehaviour.ToString()NetworkBehaviour.Reset()NetworkBehaviour.OnValidate()NetworkBehaviour.IsBehaviourReconcilingNetworkBehaviour.ClearReplicateCache()NetworkBehaviour.CreateReconcile()NetworkBehaviour.Reconcile_Reader<T>(PooledReader, ref T)NetworkBehaviour.OnStartServerCalledNetworkBehaviour.OnStartClientCalledNetworkBehaviour.WritePayload(NetworkConnection, Writer)NetworkBehaviour.ReadPayload(NetworkConnection, Reader)NetworkBehaviour.OnStartNetwork()NetworkBehaviour.OnStopNetwork()NetworkBehaviour.OnStartServer()NetworkBehaviour.OnStopServer()NetworkBehaviour.OnOwnershipServer(NetworkConnection)NetworkBehaviour.OnSpawnServer(NetworkConnection)NetworkBehaviour.OnDespawnServer(NetworkConnection)NetworkBehaviour.OnStartClient()NetworkBehaviour.OnStopClient()NetworkBehaviour.OnOwnershipClient(NetworkConnection)NetworkBehaviour.ClearBuffedRpcs()NetworkBehaviour.ExcludeOwnerFromUnbufferedObserversRpcsNetworkBehaviour.IsClientOnlyNetworkBehaviour.IsServerOnlyNetworkBehaviour.IsHostNetworkBehaviour.IsClientNetworkBehaviour.IsServerNetworkBehaviour.IsDeinitializingNetworkBehaviour.NetworkManagerNetworkBehaviour.ServerManagerNetworkBehaviour.ClientManagerNetworkBehaviour.ObserverManagerNetworkBehaviour.TransportManagerNetworkBehaviour.TimeManagerNetworkBehaviour.SceneManagerNetworkBehaviour.PredictionManagerNetworkBehaviour.RollbackManagerNetworkBehaviour.NetworkObserverNetworkBehaviour.IsClientInitializedNetworkBehaviour.IsClientStartedNetworkBehaviour.IsClientOnlyInitializedNetworkBehaviour.IsClientOnlyStartedNetworkBehaviour.IsServerInitializedNetworkBehaviour.IsServerStartedNetworkBehaviour.IsServerOnlyInitializedNetworkBehaviour.IsServerOnlyStartedNetworkBehaviour.IsHostInitializedNetworkBehaviour.IsHostStartedNetworkBehaviour.IsOfflineNetworkBehaviour.IsNetworkedNetworkBehaviour.GetIsNetworked()NetworkBehaviour.IsManagerReconcilingNetworkBehaviour.ObserversNetworkBehaviour.IsOwnerNetworkBehaviour.IsControllerNetworkBehaviour.HasAuthorityNetworkBehaviour.OwnerNetworkBehaviour.OwnerIdNetworkBehaviour.ObjectIdNetworkBehaviour.LocalConnectionNetworkBehaviour.OwnerMatches(NetworkConnection)NetworkBehaviour.Despawn(GameObject, DespawnType?)NetworkBehaviour.Despawn(NetworkObject, DespawnType?)NetworkBehaviour.Despawn(DespawnType?)NetworkBehaviour.Spawn(GameObject, NetworkConnection, Scene)NetworkBehaviour.Spawn(NetworkObject, NetworkConnection, Scene)NetworkBehaviour.RemoveOwnership()NetworkBehaviour.GiveOwnership(NetworkConnection)NetworkBehaviour.GetInstance<T>()NetworkBehaviour.TryRegisterInstance<T>(T)NetworkBehaviour.UnregisterInstance<T>()NetworkBehaviour.CanLog(LoggingType)MonoBehaviour.IsInvoking()MonoBehaviour.CancelInvoke()MonoBehaviour.StopCoroutine(Coroutine)MonoBehaviour.StopAllCoroutines()MonoBehaviour.destroyCancellationTokenMonoBehaviour.useGUILayoutMonoBehaviour.didStartMonoBehaviour.didAwakeMonoBehaviour.runInEditModeBehaviour.enabledBehaviour.isActiveAndEnabledComponent.GetComponent<T>()Component.TryGetComponent<T>(out T)Component.GetComponentInChildren<T>()Component.GetComponentsInChildren<T>()Component.GetComponentInParent<T>()Component.GetComponentsInParent<T>()Component.GetComponents<T>()Component.GetComponentIndex()Component.CompareTag(TagHandle)Component.transformComponent.transformHandleComponent.gameObjectComponent.tagObject.GetEntityId()Object.GetInstanceID()Object.GetHashCode()Object.InstantiateAsync<T>(T)Object.InstantiateAsync<T>(T, Transform)Object.InstantiateAsync<T>(T, Vector3, Quaternion)Object.InstantiateAsync<T>(T, Transform, Vector3, Quaternion)Object.Instantiate(Object, Vector3, Quaternion)Object.Instantiate(Object, Vector3, Quaternion, Transform)Object.Instantiate(Object)Object.Instantiate(Object, Scene)Object.Instantiate<T>(T, InstantiateParameters)Object.Instantiate<T>(T, Vector3, Quaternion, InstantiateParameters)Object.Instantiate(Object, Transform)Object.Instantiate<T>(T)Object.Instantiate<T>(T, Vector3, Quaternion)Object.Instantiate<T>(T, Vector3, Quaternion, Transform)Object.Instantiate<T>(T, Transform)Object.Destroy(Object)Object.DestroyImmediate(Object)Object.DontDestroyOnLoad(Object)Object.DestroyObject(Object)Object.FindObjectsOfType<T>()Object.FindObjectsByType<T>(FindObjectsSortMode)Object.FindObjectsByType<T>(FindObjectsInactive, FindObjectsSortMode)Object.FindObjectOfType<T>()Object.FindFirstObjectByType<T>()Object.FindAnyObjectByType<T>()Object.FindFirstObjectByType<T>(FindObjectsInactive)Object.FindAnyObjectByType<T>(FindObjectsInactive)Object.FindObjectsByType<T>()Object.FindObjectsByType<T>(FindObjectsInactive)Object.nameObject.hideFlags
- Extension Methods
Remarks
Why the distance LOD is required. State forwarding is off on every character, so a
NetworkTransform is the only thing that carries a character's position to anyone
observing it — and an unfiltered NetworkTransform sends every observer every update at
full tick rate regardless of distance. NetworkTransformDistanceLod is what
installs the per-observer send filter that bands those updates by distance; without it a
character is the single largest line in every observer's budget. It in turn requires the
NetworkTransform itself, so this one attribute pins the whole interpolated transport
onto every character that ships.
Fields
Behaviours
Dictionary mapping behaviour interface types to their implementations for this character.
protected Dictionary<Type, ICharacterBehaviour> Behaviours
Field Value
ClientCharacters
Client-side dictionary mapping character IDs to their instances for quick lookup. This is populated when characters are read from the network payload and cleared when they are destroyed. Characters are also removed from this dictionary when their state is reset, such as during despawning or scene transitions.
public static Dictionary<long, ICharacter> ClientCharacters
Field Value
Properties
CharacterGuildLabel
The label displaying the character's guild above their model.
public WorldLabel CharacterGuildLabel { get; set; }
Property Value
CharacterNameLabel
The label displaying the character's name above their model.
public WorldLabel CharacterNameLabel { get; set; }
Property Value
Collider
Collider attached to the character, used for physics and interactions.
public Collider Collider { get; set; }
Property Value
- Collider
Flags
Bitwise flags representing character state and attributes.
public int Flags { get; set; }
Property Value
GameObject
Cached reference to the character's GameObject.
public GameObject GameObject { get; }
Property Value
- GameObject
ID
Unique network identifier for this character.
public long ID { get; set; }
Property Value
IsTeleporting
Indicates if the character is currently teleporting. Override in derived classes for custom logic.
public virtual bool IsTeleporting { get; }
Property Value
LocalTick
The current local TimeManager tick for this character's context. Exposed as a convenience for callers that need the absolute tick.
public uint LocalTick { get; }
Property Value
MeshRoot
The root transform for the character's mesh/model hierarchy.
public Transform MeshRoot { get; }
Property Value
- Transform
Name
The name of the character, mapped to the GameObject's name.
public string Name { get; }
Property Value
NetworkAnimator
NetworkAnimator component for synchronizing animation parameters across the network. Configured at runtime after the character model is instantiated.
public NetworkAnimator NetworkAnimator { get; }
Property Value
- NetworkAnimator
Transform
Cached reference to the character's Transform component.
public Transform Transform { get; }
Property Value
- Transform
Methods
DisableFlags(CharacterFlags)
Disables the specified character flags using bitwise operations.
public void DisableFlags(CharacterFlags flags)
Parameters
flagsCharacterFlagsFlags to disable.
EnableFlags(CharacterFlags)
Enables the specified character flags using bitwise operations.
public void EnableFlags(CharacterFlags flags)
Parameters
flagsCharacterFlagsFlags to enable.
Get<T>()
Retrieves a registered character behaviour for the specified interface type, or null if not found.
public T Get<T>() where T : class, ICharacterBehaviour
Returns
- T
The behaviour instance if found; otherwise, null.
Type Parameters
TThe interface type to retrieve.
InstantiateRaceModelFromIndex(RaceTemplate, int)
Instantiates the character's race model prefab at the specified index and attaches it to the mesh root. Removes any previous child models except for labels and special points.
public void InstantiateRaceModelFromIndex(RaceTemplate raceTemplate, int modelIndex)
Parameters
raceTemplateRaceTemplateThe race template containing model references.
modelIndexintThe index of the model to instantiate.
InstantiateRaceModelFromIndex(RaceTemplate, int, CharacterGender)
Instantiates the character's race model prefab at the specified gender and index and attaches it to the mesh root. Removes any previous child models except for labels and special points.
public void InstantiateRaceModelFromIndex(RaceTemplate raceTemplate, int modelIndex, CharacterGender gender)
Parameters
raceTemplateRaceTemplateThe race template containing model references.
modelIndexintThe index of the model to instantiate.
genderCharacterGenderThe model gender to request.
Invoke(List<Trigger>, EventData)
Executes each trigger in the list with the supplied event data.
Null-safe: no-ops if triggers or eventData is null.
public void Invoke(List<Trigger> triggers, EventData eventData)
Parameters
triggersList<Trigger>The list of triggers to execute.
eventDataEventDataThe event data to pass to each trigger.
IsFlagged(CharacterFlags)
Checks if the specified character flags are enabled.
public bool IsFlagged(CharacterFlags flags)
Parameters
flagsCharacterFlagsFlags to check.
Returns
- bool
True if the flags are enabled; otherwise, false.
OnAwake()
Called after all CharacterBehaviours have called InitializeOnce. Override for custom initialization logic.
public virtual void OnAwake()
OnDestroying()
Called when the object is being destroyed. Override for custom cleanup logic.
public virtual void OnDestroying()
RegisterCharacterBehaviour(ICharacterBehaviour)
Registers a character behaviour implementation for all supported interfaces. Only interfaces derived from ICharacterBehaviour are registered.
public void RegisterCharacterBehaviour(ICharacterBehaviour behaviour)
Parameters
behaviourICharacterBehaviourThe behaviour instance to register.
TryGet<T>(out T)
Attempts to retrieve a registered character behaviour for the specified interface type.
public bool TryGet<T>(out T control) where T : class, ICharacterBehaviour
Parameters
controlTThe behaviour instance if found, otherwise null.
Returns
- bool
True if the behaviour is found; otherwise, false.
Type Parameters
TThe interface type to retrieve.
UnregisterCharacterBehaviour(ICharacterBehaviour)
Unregisters a character behaviour implementation for all supported interfaces. Removes the behaviour from the dictionary for each interface it implements.
public void UnregisterCharacterBehaviour(ICharacterBehaviour behaviour)
Parameters
behaviourICharacterBehaviourThe behaviour instance to unregister.