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.RequestReconcileSends()NetworkBehaviour.CreateReconcile()NetworkBehaviour.Reconcile_Reader_Remote<T>(PooledReader, ref T)NetworkBehaviour.ClearBuffedRpcs()NetworkBehaviour.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)NetworkBehaviour.OnStartServerCalledNetworkBehaviour.OnStartClientCalledNetworkBehaviour.WritePayload(NetworkConnection, Writer)NetworkBehaviour.ReadPayload(NetworkConnection, Reader)NetworkBehaviour.OnStartNetwork()NetworkBehaviour.OnStopNetwork()NetworkBehaviour.OnStopServer()NetworkBehaviour.OnOwnershipServer(NetworkConnection)NetworkBehaviour.OnDespawnServer(NetworkConnection)NetworkBehaviour.OnStopClient()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.MemberwiseClone()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
NoTickAimOrigin
No tick recorded yet: never a real input tick, so a reader can tell a stale origin from a current one.
public const uint NoTickAimOrigin = 4294967295
Field Value
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
OwnerLaunch
The launch line for the camera as it stood when this tick's input was built: what the ability controller sends (ConvergenceDistance and the origin offsets) on a tick that may spawn a projectile. Owner only; not given before the first input.
public AimConvergence.AimLaunch OwnerLaunch { get; }
Property Value
ShipAboard
The ship under way this character stood on at the latest tick it simulated, or default aboard none: what the owner's camera turns with (TryGetDrawnYaw(in ShipRef, out float)). Its facing and place on the deck are carried in the replicate; this is presentation only and no simulation reads it.
public FloatingBoats.ShipRef ShipAboard { get; }
Property Value
TickAimOrigin
The eye at the START of the tick last simulated (before this tick's move): the point shots of that tick are fired from (AbilityController reads it, Order 100, after the motor has moved).
public Vector3 TickAimOrigin { get; }
Property Value
- Vector3
Remarks
The start of the tick because that is the only eye the owner knows when it builds the input. The aim is converged from it (AimConvergence: eye to the crosshair's point), so the shot reaches that point only if it is fired from the same eye. Fired from the eye after the move instead, as it used to be, the shot ran parallel to the converged line, displaced by the tick's movement: about 20 cm sideways for a running strafe.
Recorded first thing, before any early return, on every pass including replays: the server, the owner and every replay reach the same motor state at the start of a tick, so they read the same eye.
TickAimOriginTick
The input tick TickAimOrigin belongs to; NoTickAimOrigin before the first.
public uint TickAimOriginTick { 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
OnSpawnServer(NetworkConnection)
Server: a connection that starts seeing this character is told its movement mode as it is now, so a swimmer, climber or flyer is drawn right from the first frame (it used to be repeated every two seconds to everyone for this). The default mode needs no message. Anyone already observing learns a change from FishMMO.Shared.KCCPlayer.PublishMovementMode(), which may repeat it to this one once.
public override void OnSpawnServer(NetworkConnection connection)
Parameters
connectionNetworkConnection
OnStartClient()
Called on the client after initializing this object.
public override void OnStartClient()
OnStartServer()
Called on the server after initializing this object. SyncTypes modified before or during this method will be sent to clients in the spawn message.
public override void OnStartServer()
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.
ResolveOwnerAim(Vector3, Quaternion, out Vector3, out Vector3, out short, out AimLaunch)
The owner's aim from a camera pose: the eye the next tick's shots leave from, the quantised direction from it to the point under the crosshair, and the body's heading offset (AimConvergence).
public void ResolveOwnerAim(Vector3 cameraPosition, Quaternion cameraRotation, out Vector3 eye, out Vector3 aimDirection, out short headingOffset, out AimConvergence.AimLaunch launch)
Parameters
cameraPositionVector3The camera.
cameraRotationQuaternionThe camera's rotation.
eyeVector3The eye at the start of the next tick (TickAimOrigin once it runs).
aimDirectionVector3The quantised aim, exactly as the wire carries it.
headingOffsetshortThe body's heading offset from the aim, as the wire carries it.
launchAimConvergence.AimLaunchThe launch line: the crosshair's own line, as the wire carries it (AimConvergence.LaunchLine).
Remarks
The one definition of "where the shot goes", used by the input (PopulateInput(ref CharacterReplicateData)) and by the target the crosshair highlights (TargetController.Update). Both trace the same line, so the target shown under the crosshair is the one the cast's own trace finds: over the shoulder the camera can see past a corner the eye cannot, and a highlight taken along the camera's ray would offer a target the shot can never reach.
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, float, Vector3)
Updates the camera with scroll and look input, over deltaTime seconds.
public void UpdateCamera(float deltaTime, float scrollInput, Vector3 lookInputVector)
Parameters
deltaTimefloatSeconds since the camera was last updated.
scrollInputfloatScroll/zoom input.
lookInputVectorVector3Look input vector.
Remarks
The time is the caller's FRAME time. This is called once a frame, and it used to hand the camera the length of a tick whatever the frame took, so everything the camera eases (the zoom, a boom let out after an obstruction) ran nearly five times too fast at 144 frames a second and at the authored speed only at 30. The caller passes it in because no file of the prediction path reads a wall clock itself.