A complete, production-ready character controller system for Unity featuring both first-person and third-person camera perspectives with advanced movement mechanics, animation blending, and input handling using Unity's new Input System.
- Multiple Movement States: Idle, Walk, Run, Sprint, Jump, Fall
- Smooth Movement Transitions: Acceleration-based movement with customizable drag
- Advanced Ground Detection: Reliable grounding with sphere-cast validation
- Slope Handling: Automatic wall sliding on steep surfaces
- Configurable Physics: Adjustable gravity, terminal velocity, and jump mechanics
- Diagonal Movement Restriction: Optional sprint limitation for directional movement
- First-Person & Third-Person Support: Pre-configured prefabs for both perspectives
- Smooth Camera Rotation: Mouse/gamepad look with adjustable sensitivity
- Vertical Look Clamping: Prevents over-rotation with configurable limits
- Camera Distance Control: Third-person zoom with mouse scroll
- Smart Player Rotation: Automatic character rotation to camera direction with idle turning animations
- Blend Tree Integration: 8-directional movement (forward, backward, left, right, and diagonals)
- Movement Speed Blending: Smooth transitions between walk, run, and sprint animations
- Action Animations: Attack and gathering animations with interrupt handling
- Aerial Animations: Dedicated jump and fall animations with directional support
- Rotation Animations: 90-degree turn animations for idle state
- Upper Body Masking: Separate control for upper body actions during movement
- Unity Input System: Modern input handling with rebinding support
- Multiple Control Schemes: Keyboard & Mouse, Gamepad, Touch, XR
- Toggle & Hold Options: Configurable sprint behavior (hold vs toggle)
- Walk Mode Toggle: Optional walking mode for precise movement
- Action Inputs: Separate action map for attacks and gathering
- Modular Input Architecture: Clean separation between input handling and game logic
- On-Screen Virtual Joysticks: Touch-based movement and camera controls
- Mobile UI Canvas: Responsive mobile layout with proper scaling
- Touch Button Controls: Jump, Punch, and Gather actions via touch buttons
- Camera Swap Button: Toggle between first-person and third-person camera views
- Platform-Specific Sensitivity: Separate sensitivity settings for mobile vs desktop
Core logic components:
- PlayerController.cs - Main movement controller with physics and camera handling
- PlayerAnimation.cs - Animation state management and blend tree control
- PlayerState.cs - Movement state machine and state queries
- CharacterControllerUtils.cs - Utility functions for ground detection
- Input/ - Modular input system components
PlayerInputManager.cs
- Singleton input managerPlayerLocomotionInput.cs
- Movement and camera inputPlayerActionsInput.cs
- Action input (attack, gather)ThirdPersonInput.cs
- Third-person camera controls
Ready-to-use character controllers:
- FirstPersonController.prefab - First-person configuration with camera setup
- ThirdPersonController.prefab - Third-person configuration with Cinemachine camera
- InputManager.prefab - Persistent input manager singleton
Unity Input System assets:
- PlayerControls.inputactions - Input action definitions
- PlayerControls.cs - Auto-generated C# wrapper for input actions
Complete animation system:
- PlayerAnimator.controller - Animator controller with blend trees and transitions
- UpperBody.mask - Avatar mask for upper body animations
- Movement animations: Idle, Walk, Run, Sprint (all 8 directions)
- Action animations: PunchRight, Gathering
- Aerial animations: Jump variations, Falling loops
- Turn animations: 90-degree left/right turns
- FBX files - Source animation files
Example materials:
- GroundMat.mat - Ground surface material
- ObstacleMat.mat (x3) - Obstacle materials with variations
Unity project settings:
- PlayerSettings.preset - Recommended player settings for the character controller
- TagManager.preset - Required tags and layers configuration
Low-poly character assets:
- Character meshes (optimized for games)
- Character materials and textures
- Pre-configured character prefabs
- Unity Version: 2021.3 LTS or newer
- Unity Packages:
- Input System (com.unity.inputsystem) - v1.0.0+
- Cinemachine (com.unity.cinemachine) - v3.0.0+ (for third-person controller)
- Rendering Pipeline: Universal Render Pipeline (URP) recommended
- Download the
.unitypackage
file - In Unity, go to Assets > Import Package > Custom Package
- Select the downloaded package and click Import
- Import all contents or select specific folders as needed
- Copy the
CameraCharacterController
folder - Paste into your Unity project's
Assets
folder - Unity will automatically import and compile the scripts
-
Apply Project Settings:
- Go to
Assets/Alex/CameraCharacterController/Presets/
- Apply
TagManager.preset
to configure required layers - Apply
PlayerSettings.preset
for optimal settings (optional)
- Go to
-
Install Required Packages:
- Open Window > Package Manager
- Install "Input System" if not already installed
- Install "Cinemachine" if using third-person controller
-
Configure Input System:
- When prompted, allow Unity to restart after enabling the new Input System
- Ensure "Both" or "New Input System" is selected in Edit > Project Settings > Player > Active Input Handling
-
Add Input Manager to Scene:
Drag 'InputManager.prefab' into your scene hierarchy This prefab uses DontDestroyOnLoad and manages all input
-
Add Character Controller:
Drag either 'FirstPersonController.prefab' or 'ThirdPersonController.prefab' into your scene Position the character at your desired spawn point
-
Configure Ground Layers:
- Select the character controller in the hierarchy
- In the Inspector, find the
Player Controller
component - Set "Ground Layers" to include your ground/floor layer(s)
-
Test the Setup:
- Press Play
- Use WASD/Arrow Keys to move
- Use Mouse to look around
- Press Space to jump
- Hold Left Shift to sprint
- Press Left Click for attack
- Press E for gather action
- Movement: WASD or Arrow Keys
- Look: Mouse movement
- Jump: Spacebar
- Sprint: Left Shift (hold or toggle - configurable)
- Walk: Left Ctrl (toggle)
- Attack: Left Mouse Button
- Gather: E key
- Zoom (Third-Person): Mouse Scroll Wheel
- Movement: Left Stick
- Look: Right Stick
- Jump: A Button (Xbox) / X Button (PlayStation)
- Sprint: Left Stick Press (L3)
- Attack: Y Button (Xbox) / Triangle (PlayStation)
- Movement: Left virtual joystick (On-Screen Stick)
- Look Around: Right virtual joystick (On-Screen Stick)
- Jump: Touch button
- Punch: Touch button
- Gather: Touch button
- Camera Swap: Camera toggle button (switches between first-person and third-person views)
The system supports seamless switching between first-person and third-person camera perspectives:
- Camera Toggle: Press V key to switch between camera modes
- Third-Person Default: The system starts in third-person mode by default
- Smooth Transitions: Character position and rotation are preserved during camera switches
- Camera Button: Tap the camera swap button in the mobile UI to toggle camera modes
- Visual Feedback: Button provides clear indication of current camera mode
- Touch Integration: Works seamlessly with other mobile controls
- Position Synchronization: Characters maintain their exact position when switching cameras
- Input System Management: All movement and action controls work correctly in both camera modes
- State Preservation: Movement state, animations, and input handling are properly maintained
- Cross-Platform: Camera switching works identically on desktop and mobile platforms
To use camera switching, ensure both controller prefabs are in your scene:
- ThirdPersonController: Contains Cinemachine-based third-person camera
- FirstPersonController: Contains first-person camera setup
- MobileControls: UI canvas with camera swap button (for mobile)
The camera switching system automatically manages input callbacks and component states to ensure smooth operation.
Select your character controller and adjust in the Player Controller component:
Base Movement
Walk Speed
- Speed when walking (default: 2)Run Speed
- Normal running speed (default: 4)Sprint Speed
- Maximum sprint speed (default: 7)Walk/Run/Sprint Acceleration
- How quickly each speed is reachedDrag
- Ground movement decelerationIn Air Drag
- Air movement deceleration
Jump & Gravity
Gravity
- Downward acceleration (default: 25)Jump Speed
- Initial jump velocity multiplier (default: 0.8)Terminal Velocity
- Maximum falling speed (default: 50)
Camera Settings
Look Sense H
- Horizontal look sensitivity (default: 0.1)Look Sense V
- Vertical look sensitivity (default: 0.1)Look Limit V
- Vertical look angle limit in degrees (default: 89)
Mobile Camera Settings
Mobile Mutliplier
- Sensitivity multiplier for mobile devices (default: 3.0)
Animation
Player Model Rotation Speed
- How fast the character rotates to face camera direction (default: 10)Rotate To Target Time
- Duration of idle turning animation (default: 0.67)
To modify input mappings:
- Open
Assets/Alex/CameraCharacterController/Input/PlayerControls.inputactions
- Edit action bindings in the Input Actions editor
- Unity will auto-regenerate the C# wrapper file
Sprint Behavior:
- Select the character controller
- Find
Player Locomotion Input
component - Toggle
Hold To Sprint
(checked = hold, unchecked = toggle)
The PlayerAnimator.controller
uses blend trees for:
- Locomotion Blend Tree: 8-directional movement based on
inputX
,inputY
, andinputMagnitude
- Speed Layers: Walk (0-0.5), Run (0.5-1.0), Sprint (1.0-1.5)
To add custom animations:
- Import your animation files
- Add them to the appropriate blend tree in the Animator Controller
- Adjust blend tree thresholds as needed
To add new actions (e.g., crouch, roll):
-
Add Input Action:
- Open
PlayerControls.inputactions
- Add new action to
PlayerActionMap
- Assign key binding
- Open
-
Handle in Code:
- Edit
PlayerActionsInput.cs
- Add property:
public bool CrouchPressed { get; private set; }
- Implement callback:
public void OnCrouch(InputAction.CallbackContext context)
- Add to interface implementation
- Edit
-
Add Animation:
- Add animator parameter in
PlayerAnimator.controller
- Create animation state and transitions
- Set animation parameter in
PlayerAnimation.cs
- Add animator parameter in
The system uses Unity's DefaultExecutionOrder
attribute:
- -3:
PlayerInputManager
(reads input first) - -2: All input components (process input)
- -1:
PlayerController
(applies movement) - 0:
PlayerAnimation
,PlayerState
(update visuals)
PlayerInputManager (Singleton)
↓
PlayerLocomotionInput ←─┐
PlayerActionsInput │
ThirdPersonInput │ (All reference PlayerInputManager.Instance)
↓ │
PlayerController ───────┘
↓
PlayerAnimation
PlayerState
- Ensure InputManager prefab is in the scene
- Check that Player Controller component's "Ground Layers" includes your floor
- Verify Unity Input System is enabled in Project Settings
- Third-Person: Ensure Cinemachine is installed and camera's "Follow" target is set to character
- First-Person: Check that camera is child of character object
- Verify Animator component has
PlayerAnimator
controller assigned - Check that character model has a properly configured Avatar
- Ensure all animation parameters exist in the Animator Controller
- Check
PlayerControls.inputactions.meta
has correct namespace:Alex.CameraCharacterController
- Reimport the PlayerControls.inputactions file to regenerate C# wrapper
- Ensure Input System package is installed and active
- Ensure EventSystem is present in the scene with Input System UI Input Module
- Check Canvas Render Mode is set to Screen Space - Overlay or Screen Space - Camera
- Verify Canvas Scaler settings for proper mobile scaling
- Ensure mobile UI elements are on the "UI" layer
- If you see "PlayerControls could not be found" errors:
- Select
PlayerControls.inputactions
in Project window - In Inspector, verify "Generate C# Class" is enabled
- Check "Namespace" field shows
Alex.CameraCharacterController
- Click "Apply" to regenerate the code
- Select
- Ground Detection: Uses optimized sphere cast only when needed
- Animation Blending: Smoothed over time to reduce frame-to-frame changes
- Physics: Single
CharacterController.Move()
call per frame - Low-Poly Models: Included character models are optimized for real-time rendering
Character Controller System
- Developed by: Alex
- Namespace:
Alex.CameraCharacterController
- Based on tutorial by: spaderdabomb
- YouTube: @spaderdabomb
- GitHub: spaderdabomb
Included Assets
- Low-poly character models: FREE_HumanLowPoly
- Built with Unity Input System
- Cinemachine integration for third-person camera
v1.0
- Initial release
- First and third-person controllers
- Complete animation system
- Unity Input System integration
- Gamepad support
- Action system with attack and gather
v1.1
- Added mobile touch controls support
- On-screen virtual joysticks for movement and camera
- Touch buttons for Jump, Punch, and Gather actions
- Platform-specific sensitivity settings
- Mobile UI Canvas with proper scaling
For issues, questions, or contributions:
- Check the Troubleshooting section above
- Verify all requirements are met
- Ensure latest version of required packages are installed
Note: This package uses the Alex.CameraCharacterController
namespace. Ensure no conflicting namespaces exist in your project.