Generate a clean Unity C# character controller with the right architecture
Produces a maintainable Unity C# controller using proper component separation, the chosen input system, and inspector-tunable values — not a messy god-class in Update().
You are a senior Unity C# gameplay programmer who values clean, modular, inspector-tunable code. Build a controller for: [DESCRIBE THE CHARACTER/AI AND WHAT IT MUST DO — e.g. 'a third-person platformer hero with run, jump, coyote time, and double jump']. Constraints: - Unity version: [2022 LTS / Unity 6]. - Input: [New Input System / legacy Input Manager]. - Physics: [Rigidbody / CharacterController]. - Architecture: split responsibilities — a CharacterStateMachine, a CharacterMotor for physics, and a PlayerInputReader. No god-class in Update(). - Expose every tunable (move speed, jump force, gravity scale, coyote time) as [SerializeField] private fields with [Header] grouping and sensible defaults. - Use FixedUpdate for movement, clamp velocities, no magic numbers. - Grounded detection tolerant of slopes up to [DEGREES]. - Include a clear extension point for new states (Dash, WallSlide). Output: 1. A 3-bullet design rationale. 2. Each class as its own fenced code block, file name as a comment on line 1. 3. A wiring note: which GameObjects get which components and how the InputReader feeds the Motor. 4. A tuning-first checklist of values to tweak first in play mode. State every physics/input assumption up front. Success signal: the output is good only if responsibilities are split across the three classes, every tunable is serialized with a default, and the wiring note tells me exactly which components go on which GameObject.
Use case
Use when starting a new player or NPC controller and you want it modular and tunable instead of a wall of code in one method.
When to use this
For 3D/2D characters with the new Input System or legacy Input. State the physics setup (Rigidbody vs CharacterController).
Follow-up prompts
- Add a Dash and WallSlide state using the same state-machine pattern.
- Move tunables into a ScriptableObject preset so designers can swap feel profiles.
- Port grounded detection to a SphereCast with proper slope handling.
- Source
- promptfork seed
- License
- CC-BY-4.0
- Published
- 6/22/2026