You are viewing a potentially older version of this package. View all versions.
weedeater_png-Optimized_Kinematic_Character_Controller-3.0.0 icon

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 30% increase in performance

Date uploaded 3 weeks ago
Version 3.0.0
Download link weedeater_png-Optimized_Kinematic_Character_Controller-3.0.0.zip
Downloads 39
Dependency string weedeater_png-Optimized_Kinematic_Character_Controller-3.0.0

README

Mod description

This time The Mod Creator tested the mod instead of The Tester. What Mod Creator has to say: "I don't understand profilers. Numbers are all inconsistent. I can't fact check the differences. I can only say that now I get 110 fps on average during 30 Lemurians test instead of 80 in the previous version. Full run tests are needed"

Rundown on what Gemini did for optimizing:

Performance Optimizations (Quality Sacrificed for Speed)

Clamped Movement Sweeps (InternalCharacterMove):

Standard KCC runs up to 6 iterative collision sweeps per entity tick (MaxMovementIterations = 6).
The optimized motor caps movement iterations to 2 for player characters (ensuring smooth wall sliding) and 1 for monsters/enemies.
An early-out check immediately skips sweeping if remaining movement magnitude or velocity is negligible (< 0.001f).

Single-Pass De-penetration:

Standard KCC executes 3 iterative de-collision passes in Phase 1 and another 3 in Phase 2, calling PhysX Physics.ComputePenetration and Physics.OverlapCapsuleNonAlloc repeatedly.
The optimized motor executes at most 1 pass and resolves only the foremost overlapping contacts.

Fast-Path Ground Probing & Stability:

Stable grounded entities with low vertical velocity bypass multi-angle rebound sweeps in ProbeGround.
Secondary entities bypass extra ledge raycasts (stabilityReport.FoundInnerNormal / FoundOuterNormal) in EvaluateHitStability, saving thousands of raycasts per frame in crowded arenas.
Step detection sweeps are skipped when already on a stable slope or step height is zero.

Staggered Simulation for Low-Velocity Monsters:

Hopoo implemented CharacterMotors_Important and IsImportantByVelocity, but left ReevaluateImportance() uncalled in standard RoR2, forcing all monsters to run full expensive updates every tick.
KinematicCharacterSystem now re-evaluates character importance periodically (every 10 ticks), placing idle/slow distant monsters in the time-sliced staggered update loop while player and high-velocity monsters receive full updates.
Empty debug overhead (DebugExpensiveCheckForGround) is removed.

Jobs & Burst Architecture
1. Burst-Compiled Math Jobs (KCCJobs.cs)

Vector math, plane projections, and collision impulse calculations are encapsulated into Burst-compiled IJob / IJobParallelFor structs:

EvaluateCreaseJob : IJob: Vectorized SIMD evaluation of corner and crease normals.
VelocityProjectionJob : IJob: Surface tangent and velocity projection onto obstruction planes.
CollisionResolutionJob : IJob: Dynamic collision impulse and momentum exchange.
GroundStabilityJob : IJob: Fast slope dot-product stability check.
CharacterInterpolationJob : IJobParallelForTransform: Parallel transform interpolation during LateUpdate.
BatchInterpolateJob : IJobParallelFor: Contiguous array SIMD lerp/slerp.
SetTransformJob & PostSimSetTransformJob: Parallel transform resets.

2. Job-Compatible Physics Alternatives (KCCPhysicsJobs.cs)

Because standard PhysX methods cannot run on worker threads, Job-compatible alternatives using Unity's command batching system are implemented:

CapsulecastCommand.ScheduleBatch via KCCPhysicsJobs.ScheduleCapsuleCastBatch
RaycastCommand.ScheduleBatch via KCCPhysicsJobs.ScheduleRaycastBatch
SpherecastCommand.ScheduleBatch via KCCPhysicsJobs.ScheduleSphereCastBatch
PrepareCapsuleSweepCommandsJob : IJobParallelFor: Prepares capsule sweep commands in parallel from character positions.
PrepareRaycastCommandsJob : IJobParallelFor: Prepares raycast commands in parallel.
FilterHitResultsJob : IJobParallelFor: Post-processes and clamps hit distances across worker threads.

3. New Motor Job Methods on KinematicCharacterMotor
motor.CreateCapsuleCastCommand(...)
motor.CreateGroundSweepCommand(...)
motor.CreateRaycastCommand(...)
KinematicCharacterMotor.ScheduleCharacterSweep(...)
KinematicCharacterMotor.ScheduleCharacterRaycast(...)
KinematicCharacterMotor.ScheduleGroundSweep(...)

The model used: Gemini 3.8 Flash Medium.

I wish I had Gemini 4 Argon right now but I am not gonna pay anything for AI

CHANGELOG

Repromted Gemini to redo everything again. Hand coded proper Burst library load