
You are viewing a potentially older version of this package. View Latest Version
Optimized Kinematic Character Controller
Replaces games KinematicCharacterController assembly with a version modified by Gemini AI to sacrifice quality for performance and Bursts some Jobs. Expect atleast 50% increase in performanceMod description
This time the Mod Creator tested the mod instead of The Tester. What Mod Creator has to say: "Looks like it is twice as performant as base game KCC. Little hop on landing is a bit annoying. I will try fixing it later."
Rundown on what Gemini did for optimizing:
Drastic PhysX Call Reductions:
Single-Pass De-collision: Reduced the 3-pass loop in Phase 1 and Phase 2 down to at most 1 pass. If no overlapping colliders are found, it skips immediately.
Initial Overlap Bypass: In KinematicCharacterMotor.cs, CheckMovementInitialOverlaps is only evaluated on the first movement iteration when overlapping colliders are already known. Subsequent movement steps omit redundant overlap checks since the capsule sweeps through verified free space.
Clamped Movement Iterations: Reduced movement sweeps from 6 down to 2 for player characters (sufficient for smooth wall sliding) and 1 for non-player characters/monsters.
Streamlined Ground Probing: ProbeGround executes a single downward sweep, eliminating secondary multi-angle deflection rebounds.
Fast-Path Ledge & Step Handling: Non-player characters bypass secondary ledge raycasts entirely. Step detection uses a single forward-down check rather than 5 nested PhysX queries.
Rundown on what Gemini did for Bursting:
1. Replaced Static Burst Methods with Struct Jobs in KCCBurst.cs
Removed manual CompileFunctionPointer, delegates, and runtime DLL loading (BurstRuntime.LoadAdditionalLibrary).
Added the following [BurstCompile] struct jobs:
VelocityProjectionJob : IJob: Vectorized velocity projection against obstruction normals, ground tangents, and planes.
EvaluateCreaseJob : IJob: Evaluates whether two intersecting surfaces form a slideable crease or a blocking corner.
CollisionResolutionJob : IJob: Calculates 1D momentum/impulse exchange between character and dynamic rigidbodies based on their mass ratio.
ObstructionNormalJob : IJob: Reorients hit normals tangent to ground slope when grounded.
MovementHitVelocityProjectionJob : IJob: Performs the iterative movement hit state machine (crease checks, corner stops, velocity redirection, and remaining movement magnitude/direction scaling).
SolveOverlapConstraintsJob : IJob: Solves all pre-movement penetrating overlap constraints in Burst in a single pass.
EvaluateHitStabilityJob : IJob: Full slope angle checks, inner/outer normal angle comparisons, and ledge geometry calculations (ledge facing, right vectors, distance from ledge, and snap velocity limits).
RigidbodyMovementVelocityJob : IJob: Computes linear and tangential platform velocity transferred to the character at contact point from rotating bodies.
DepenetrationResolutionJob : IJob: Depenetration priority protection and vector combination (eliminating opposing components against static world geometry).
SurfaceTangentJob : IJob: Computes surface tangent direction vector orthogonal to character up.
PlanarConstraintJob : IJob: Projects character motion onto constraint planes.
BatchInterpolateJob : IJobParallelFor: Vectorized SIMD multi-threaded lerp & slerp across character transforms.
2. Offloaded Physics in KinematicCharacterMotor.cs
Overlap Constraints: Replaced the managed _overlaps loop in InternalCharacterMove with SolveOverlapConstraintsJob.Run().
Movement Hit Projection: InternalHandleVelocityProjection now executes MovementHitVelocityProjectionJob.Run().
Ledge & Hit Stability Math: EvaluateHitStability now executes EvaluateHitStabilityJob.Run() for all geometric and angular evaluations.
Surface Tangents & Planar Constraints: GetDirectionTangentToSurface and planar movement constraints now run SurfaceTangentJob.Run() and PlanarConstraintJob.Run().
Platform Tangential Velocity: GetVelocityFromRigidbodyMovement now runs RigidbodyMovementVelocityJob.Run().
Depenetration Resolution: Decollision priority projection now runs DepenetrationResolutionJob.Run().
Maintained 100% backward compatibility for all public virtual methods (HandleVelocityProjection, EvaluateHitStability, etc.).
3. Parallel Batch Transform Interpolation in KinematicCharacterSystem.cs
Replaced managed fixed arrays and static function pointers with persistent NativeArray<float3> and NativeArray<quaternion> buffers.
CustomInterpolationUpdate now runs BatchInterpolateJob across worker threads with job.Schedule(totalMotors, 64).Complete().
Added automatic capacity resizing and proper buffer disposal in OnDestroy.