Class KCCPlayer
Movement subsystem for KCC-based prediction. Implements IPredictableController so that CharacterPredictionController drives replication and reconciliation through a single unified pipeline.
public class KCCPlayer : NetworkBehaviour, IPredictableController
- Inheritance
-
ObjectComponentBehaviourMonoBehaviourNetworkBehaviourKCCPlayer
- Implements
- 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.OnStopClient()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
Fields
CharacterCamera
The camera controller for third-person view.
public KCCCamera CharacterCamera
Field Value
CharacterController
The character controller for movement and state logic.
public KCCController CharacterController
Field Value
Motor
The motor for kinematic character movement.
public KinematicCharacterMotor Motor
Field Value
- KinematicCharacterMotor
ObserverPredictionWindowTicks
How many ticks past the last real input an observing client may keep re-simulating that input before it stops carrying it forward.
public uint ObserverPredictionWindowTicks
Field Value
Remarks
Currently inert. The block that reads this only runs for a non-owner, non-server
peer, and a client is never handed another character's replicate input while state
forwarding is off — Replicate_NonAuthoritative returns before invoking the
replicate body, and forwarding is 0 on all 39 networked objects in this project.
Observers see other players through NetworkTransform instead. So changing this
value has no effect today; it becomes live only if forwarding is enabled.
The value would then want to be near the client's buffered-input depth — about 6 ticks at 200ms and tick rate 30 — because a window of 1 lets an observed character stall for a tick whenever an input is late. It is a plain public field serialized on all nine character prefabs, so raising it means editing those prefabs, not this default.
OnHandleCharacterInput
Delegate for handling character input (owner only). Returns KCCInputReplicateData which is converted to the unified CharacterReplicateData by PopulateInput(ref CharacterReplicateData).
public Func<KCCInputReplicateData> OnHandleCharacterInput
Field Value
Properties
Order
Execution order for this controller during the prediction tick. Lower values run first. Movement should run before abilities so that camera/position state is fresh for ability aiming.
public int Order { get; }
Property Value
Methods
OnCreateReconcile(ref CharacterReconcileData)
Writes this controller's authoritative state into the reconcile data (server only). Called once per tick after OnReplicate(ref CharacterReplicateData, ReplicateState, Channel).
public void OnCreateReconcile(ref CharacterReconcileData reconcileData)
Parameters
reconcileDataCharacterReconcileData
OnOwnershipClient(NetworkConnection)
Called when the local client gains ownership. Binds the main camera for the case where ownership arrives after OnStartClient.
public override void OnOwnershipClient(NetworkConnection prevOwner)
Parameters
prevOwnerNetworkConnection
OnReconcile(CharacterReconcileData, Channel)
Restores this controller's state from the server's authoritative reconcile data.
public void OnReconcile(CharacterReconcileData rd, Channel channel)
Parameters
rdCharacterReconcileDatachannelChannel
Remarks
The owner always reconciles — this is the correction that repairs its own predicted movement.
A non-owner only reconciles a forwarded object, because that is the only mode in which
the reconcile is what positions this character on an observing client. With forwarding
off, position arrives through NetworkTransform and applying a motor state on top
would give the transform two writers — the same failure
ApplyObserverTransportMode() exists to prevent
in the other direction. See ObserverSyncMode.
OnReplicate(ref CharacterReplicateData, ReplicateState, Channel)
Executes this controller's simulation for the current tick.
May modify input for observer prediction.
public void OnReplicate(ref CharacterReplicateData input, ReplicateState state, Channel channel)
Parameters
inputCharacterReplicateDatastateReplicateStatechannelChannel
OnStartClient()
Called when the client starts. Sets up camera following and ignored colliders for the owner.
public override void OnStartClient()
PopulateInput(ref CharacterReplicateData)
Populates this controller's portion of the unified input data (owner only). Called once per tick before OnReplicate(ref CharacterReplicateData, ReplicateState, Channel).
public void PopulateInput(ref CharacterReplicateData input)
Parameters
inputCharacterReplicateData
ResetState(bool)
Resets observer prediction state on network reset (e.g., reconnect or scene transfer).
public override void ResetState(bool asServer)
Parameters
asServerboolTrue if called on the server.
SetOrientationMethod(OrientationMethod)
Sets the orientation method for the character controller.
public void SetOrientationMethod(OrientationMethod method)
Parameters
methodOrientationMethodOrientation method to set.
SetPlatform(KCCPlatform)
Sets the current platform and snapshots its position for velocity calculation.
public void SetPlatform(KCCPlatform platform)
Parameters
platformKCCPlatformThe platform to set, or null to clear.
UpdateCamera(float, Vector3)
Updates the camera with scroll and look input, using the current tick delta.
public void UpdateCamera(float scrollInput, Vector3 lookInputVector)
Parameters
scrollInputfloatScroll/zoom input.
lookInputVectorVector3Look input vector.