Table of Contents

Class KCCController

Namespace
FishMMO.Shared
Assembly
FishMMO.Shared.dll

Kinematic Character Controller wrapper that implements KinematicCharacterController.ICharacterController. Handles movement, jumping, crouching, sprinting, and state transitions.

public class KCCController : MonoBehaviour, ICharacterController
Inheritance
Object
Component
Behaviour
MonoBehaviour
KCCController
Implements
ICharacterController
Inherited Members
MonoBehaviour.IsInvoking()
MonoBehaviour.CancelInvoke()
MonoBehaviour.StopCoroutine(Coroutine)
MonoBehaviour.StopAllCoroutines()
MonoBehaviour.destroyCancellationToken
MonoBehaviour.useGUILayout
MonoBehaviour.didStart
MonoBehaviour.didAwake
MonoBehaviour.runInEditMode
Behaviour.enabled
Behaviour.isActiveAndEnabled
Component.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.transform
Component.transformHandle
Component.gameObject
Component.tag
Object.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.ToString()
Object.name
Object.hideFlags

Fields

AirAccelerationSpeed

Acceleration applied to air movement.

public float AirAccelerationSpeed

Field Value

float

AllowJumpingWhenSliding

[Header("Jumping")]
public bool AllowJumpingWhenSliding

Field Value

bool

BonusOrientationMethod

Additional orientation method for adjusting the character up vector.

public BonusOrientationMethod BonusOrientationMethod

Field Value

BonusOrientationMethod

BonusOrientationSharpness

Sharpness for bonus orientation smoothing.

public float BonusOrientationSharpness

Field Value

float

CameraFollowPoint

Transform that the camera follows and orbits around.

public Transform CameraFollowPoint

Field Value

Transform

CapsuleBaseOffset

Base offset of the capsule from the character pivot.

public float CapsuleBaseOffset

Field Value

float

Character

The player character this controller belongs to.

public IPlayerCharacter Character

Field Value

IPlayerCharacter

CrouchedCapsuleHeight

Capsule height when crouching.

public float CrouchedCapsuleHeight

Field Value

float

Drag

Air drag coefficient applied to velocity.

public float Drag

Field Value

float

FastFallSpeedTemplate

Template for the character attribute that modifies fast fall speed.

public CharacterAttributeTemplate FastFallSpeedTemplate

Field Value

CharacterAttributeTemplate

FullCapsuleHeight

Capsule height when standing.

public float FullCapsuleHeight

Field Value

float

GravityTemplate

Template for the character attribute that modifies gravity.

public CharacterAttributeTemplate GravityTemplate

Field Value

CharacterAttributeTemplate

IgnoredColliders

[Header("Misc")]
public List<Collider> IgnoredColliders

Field Value

List<Collider>

JumpPostGroundingGraceTime

Grace period after leaving ground during which a jump is still allowed.

public float JumpPostGroundingGraceTime

Field Value

float

JumpPreGroundingGraceTime

Grace period before landing during which a jump request is still accepted.

public float JumpPreGroundingGraceTime

Field Value

float

JumpScalableForwardSpeed

Forward speed added to velocity when jumping.

public float JumpScalableForwardSpeed

Field Value

float

JumpSpeedTemplate

Template for the character attribute that modifies jump speed.

public CharacterAttributeTemplate JumpSpeedTemplate

Field Value

CharacterAttributeTemplate

MaxAirMoveSpeed

[Header("Air Movement")]
public float MaxAirMoveSpeed

Field Value

float

MeshRoot

Root transform of the character mesh for visual scaling (e.g., crouch).

public Transform MeshRoot

Field Value

Transform

Motor

The kinematic character motor driving movement and collision.

public KinematicCharacterMotor Motor

Field Value

KinematicCharacterMotor

MoveSpeedTemplate

Template for the character attribute that modifies movement speed.

public CharacterAttributeTemplate MoveSpeedTemplate

Field Value

CharacterAttributeTemplate

OrientationMethod

Method used to determine character facing direction.

public OrientationMethod OrientationMethod

Field Value

OrientationMethod

OrientationSharpness

Sharpness for character rotation smoothing.

public float OrientationSharpness

Field Value

float

SprintSpeedTemplate

Template for the character attribute that modifies sprint speed.

public CharacterAttributeTemplate SprintSpeedTemplate

Field Value

CharacterAttributeTemplate

StableMovementSharpness

[Header("Stable Movement")]
public float StableMovementSharpness

Field Value

float

SwimSpeedTemplate

Template for the character attribute that modifies swim speed.

public CharacterAttributeTemplate SwimSpeedTemplate

Field Value

CharacterAttributeTemplate

Properties

CurrentCharacterState

The current state of the character state machine.

public KCCCharacterState CurrentCharacterState { get; }

Property Value

KCCCharacterState

IsJumping

True while the character is in the jumping state.

public bool IsJumping { get; }

Property Value

bool

VirtualCameraPosition

Position of the virtual camera used for input-relative movement calculations.

public Vector3 VirtualCameraPosition { get; }

Property Value

Vector3

VirtualCameraRotation

Rotation of the virtual camera used for input-relative movement calculations.

public Quaternion VirtualCameraRotation { get; }

Property Value

Quaternion

Methods

AfterCharacterUpdate(float)

(Called by KinematicCharacterMotor during its update cycle) This is called after the character has finished its movement update

public void AfterCharacterUpdate(float deltaTime)

Parameters

deltaTime float

ApplyState(KinematicCharacterMotorState)

Applies a saved motor state to restore the character pose (used during reconcile).

public void ApplyState(KinematicCharacterMotorState state)

Parameters

state KinematicCharacterMotorState

The motor state to apply.

BeforeCharacterUpdate(float)

(Called by KinematicCharacterMotor during its update cycle) This is called before the character begins its movement update

public void BeforeCharacterUpdate(float deltaTime)

Parameters

deltaTime float

GetState()

Captures the current motor and controller state for reconciliation.

public KinematicCharacterMotorState GetState()

Returns

KinematicCharacterMotorState

A snapshot of the current kinematic state.

IsColliderValidForCollisions(Collider)

Determines if a collider is valid for collision checks, ignoring those in the IgnoredColliders list.

public bool IsColliderValidForCollisions(Collider coll)

Parameters

coll Collider

Collider to check.

Returns

bool

True if valid for collision, false if ignored.

OnDiscreteCollisionDetected(Collider)

Called when a discrete collision is detected. Can be used for collision effects.

public void OnDiscreteCollisionDetected(Collider hitCollider)

Parameters

hitCollider Collider

Collider hit.

OnGroundHit(Collider, Vector3, Vector3, ref HitStabilityReport)

Called when the character hits the ground. Can be used for landing effects or stability checks.

public void OnGroundHit(Collider hitCollider, Vector3 hitNormal, Vector3 hitPoint, ref HitStabilityReport hitStabilityReport)

Parameters

hitCollider Collider

Collider hit.

hitNormal Vector3

Normal of the hit surface.

hitPoint Vector3

Point of contact.

hitStabilityReport HitStabilityReport

Stability report for the hit.

OnLanded()

Called when the character lands on stable ground. Resets jumping state.

protected void OnLanded()

OnLeaveStableGround()

Called when the character leaves stable ground. Can be used for airborne effects.

protected void OnLeaveStableGround()

OnMovementHit(Collider, Vector3, Vector3, ref HitStabilityReport)

Called when the character hits something during movement. Can be used for collision effects.

public void OnMovementHit(Collider hitCollider, Vector3 hitNormal, Vector3 hitPoint, ref HitStabilityReport hitStabilityReport)

Parameters

hitCollider Collider

Collider hit.

hitNormal Vector3

Normal of the hit surface.

hitPoint Vector3

Point of contact.

hitStabilityReport HitStabilityReport

Stability report for the hit.

OnStateEnter(KCCCharacterState, KCCCharacterState)

Event when entering a state

public void OnStateEnter(KCCCharacterState state, KCCCharacterState fromState)

Parameters

state KCCCharacterState
fromState KCCCharacterState

OnStateExit(KCCCharacterState, KCCCharacterState)

Event when exiting a state

public void OnStateExit(KCCCharacterState state, KCCCharacterState toState)

Parameters

state KCCCharacterState
toState KCCCharacterState

PostGroundingUpdate(float)

Called after grounding update to handle landing and leaving ground events. Triggers OnLanded or OnLeaveStableGround as appropriate.

public void PostGroundingUpdate(float deltaTime)

Parameters

deltaTime float

Frame time.

ProcessHitStabilityReport(Collider, Vector3, Vector3, Vector3, Quaternion, ref HitStabilityReport)

Processes the hit stability report for advanced collision and grounding logic.

public void ProcessHitStabilityReport(Collider hitCollider, Vector3 hitNormal, Vector3 hitPoint, Vector3 atCharacterPosition, Quaternion atCharacterRotation, ref HitStabilityReport hitStabilityReport)

Parameters

hitCollider Collider

Collider hit.

hitNormal Vector3

Normal of the hit surface.

hitPoint Vector3

Point of contact.

atCharacterPosition Vector3

Character position at hit.

atCharacterRotation Quaternion

Character rotation at hit.

hitStabilityReport HitStabilityReport

Stability report for the hit.

ResetGroundProbe()

Forces a full-radius ground probe on the next motor update, so a character that has just been placed does not read as airborne for a frame or three.

public void ResetGroundProbe()

Remarks

Call this for a teleport or a fresh spawn — NOT for a reconcile, which restores LastMovementIterationFoundAnyGround authoritatively and must not have it forced.

SetInputs(ref AICharacterInputs)

This is called every frame by the AI script in order to tell the character what its inputs are

public void SetInputs(ref AICharacterInputs inputs)

Parameters

inputs AICharacterInputs

SetInputs(ref KCCInputReplicateData)

Applies one tick of replicated input. Called from KCCPlayer.OnReplicate, once per replicated or replayed tick — not per frame, despite the upstream sample's name for it.

public void SetInputs(ref KCCInputReplicateData inputs)

Parameters

inputs KCCInputReplicateData

TransitionToState(KCCCharacterState)

Handles movement state transitions and enter/exit callbacks

public void TransitionToState(KCCCharacterState newState)

Parameters

newState KCCCharacterState

UpdateRotation(ref Quaternion, float)

(Called by KinematicCharacterMotor during its update cycle) This is where you tell your character what its rotation should be right now. This is the ONLY place where you should set the character's rotation

public void UpdateRotation(ref Quaternion currentRotation, float deltaTime)

Parameters

currentRotation Quaternion
deltaTime float

UpdateVelocity(ref Vector3, float)

(Called by KinematicCharacterMotor during its update cycle) This is where you tell your character what its velocity should be right now. This is the ONLY place where you can set the character's velocity

public void UpdateVelocity(ref Vector3 currentVelocity, float deltaTime)

Parameters

currentVelocity Vector3
deltaTime float