Scripts For Unity | Free C# Scripts & Game Systems for Unity
2D Player Controller
Complete 2D character controller with smooth movement, variable-height jumping, and coyote time.
[RequireComponent(typeof(Rigidbody2D))]
public class PlayerController2D : MonoBehaviour
{
[SerializeField] private float moveSpeed = 8f;
[SerializeField] private float jumpForce = 16f;
[SerializeField] private float coyoteTime = 0.15f;3D Player Controller
First/third person character controller with smooth movement, jumping, and slope handling using C...
[RequireComponent(typeof(CharacterController))]
public class PlayerController3D : MonoBehaviour
{
[SerializeField] private float walkSpeed = 6f;
[SerializeField] private float sprintSpeed = 10f;
[SerializeField] private float jumpHeight = 1.5f;Smooth Camera Follow 2D
Smooth camera follow with offset, dead zone, and look-ahead for 2D games.
public class CameraFollow2D : MonoBehaviour
{
[SerializeField] private Transform target;
[SerializeField] private Vector3 offset = new Vector3(0f, 1f, -10f);
[SerializeField] private float smoothSpeed = 8f;Generic Singleton
Thread-safe, persistent singleton base class for managers like AudioManager, GameManager, etc.
public abstract class Singleton<T> : MonoBehaviour where T : MonoBehaviour
{
private static T instance;
public static T Instance
{
get { ... }
}First Person Camera
First person mouse look camera with sensitivity, vertical clamp, and cursor lock. Plug into any F...
public class FirstPersonCamera : MonoBehaviour
{
[SerializeField] private float mouseSensitivity = 2f;
[SerializeField] private float minVerticalAngle = -90f;
[SerializeField] private float maxVerticalAngle = 90f;Complete Inventory System
Drag-and-drop inventory with stackable items, equipment slots, and JSON save/load persistence.
Dialogue System
Node-based dialogue system with branching choices, conditions, events, and typewriter text effect.
Health System
Reusable health component with damage, healing, invincibility frames, and events.
public class HealthSystem : MonoBehaviour
{
[SerializeField] private float maxHealth = 100f;
public float HealthPercent => currentHealth / maxHealth;
public void TakeDamage(float damage)
public void Heal(float amount)2D Player Controller
Complete 2D character controller with smooth movement, variable-height jumping, and coyote time.
[RequireComponent(typeof(Rigidbody2D))]
public class PlayerController2D : MonoBehaviour
{
[SerializeField] private float moveSpeed = 8f;
[SerializeField] private float jumpForce = 16f;
[SerializeField] private float coyoteTime = 0.15f;3D Player Controller
First/third person character controller with smooth movement, jumping, and slope handling using C...
[RequireComponent(typeof(CharacterController))]
public class PlayerController3D : MonoBehaviour
{
[SerializeField] private float walkSpeed = 6f;
[SerializeField] private float sprintSpeed = 10f;
[SerializeField] private float jumpHeight = 1.5f;Smooth Camera Follow 2D
Smooth camera follow with offset, dead zone, and look-ahead for 2D games.
public class CameraFollow2D : MonoBehaviour
{
[SerializeField] private Transform target;
[SerializeField] private Vector3 offset = new Vector3(0f, 1f, -10f);
[SerializeField] private float smoothSpeed = 8f;Generic Singleton
Thread-safe, persistent singleton base class for managers like AudioManager, GameManager, etc.
public abstract class Singleton<T> : MonoBehaviour where T : MonoBehaviour
{
private static T instance;
public static T Instance
{
get { ... }
}First Person Camera
First person mouse look camera with sensitivity, vertical clamp, and cursor lock. Plug into any F...
public class FirstPersonCamera : MonoBehaviour
{
[SerializeField] private float mouseSensitivity = 2f;
[SerializeField] private float minVerticalAngle = -90f;
[SerializeField] private float maxVerticalAngle = 90f;Audio Manager
Complete audio manager with music crossfade, SFX pooling, volume control, and persistence.
public class AudioManager : MonoBehaviour
{
public static AudioManager Instance { get; private set; }
public void PlaySFX(AudioClip clip, float volumeScale = 1f)
public void PlayMusic(AudioClip clip, bool crossfade = true)Object Pool
Generic object pooling system to reduce garbage collection. Perfect for bullets, particles, and e...
public class ObjectPool : MonoBehaviour
{
public static ObjectPool Instance { get; private set; }
public GameObject Spawn(string tag, Vector3 position, Quaternion rotation)
public void Despawn(string tag, GameObject obj)Save & Load System
Flexible save system supporting multiple save slots, auto-save, and both JSON and binary serialization.
Finite State Machine
Clean, extensible state machine for AI, player states, and game flow. Uses ScriptableObject states.
2D Platformer Starter Kit
Complete 2D platformer foundation with movement, camera, advanced mechanics, health, collectibles, and transitions.
FPS Foundation Kit
First-person shooter foundation with movement, camera, weapons, projectiles, health, and screen shake.
RTS Starter Kit
Real-time strategy foundation with camera, click-to-move navigation, unit selection, minimap, and wave spawning.
RPG Essentials Kit
Core RPG systems: health, inventory, dialogue, quests, save/load, and damage numbers — everything for an RPG prototype.
Enemy AI Kit
Complete enemy AI pipeline: state machine, patrol, chase, health, and wave spawning with debug visualization.
UI Toolkit Kit
Essential game UI components: health bars, damage numbers, tooltips, minimap, screen fader, and timer display.
Hyper-Casual Starter Kit
Everything you need to prototype hyper-casual games in hours — one-tap input, endless runner template, stack mechanic, score tracking, and swipe controls.
Mobile Controls Kit
Complete touch input system for any mobile Unity game — virtual joystick, on-screen buttons, swipe gestures, pinch-to-zoom, gyroscope, and safe area handling.
Idle Game System
Core systems for idle/incremental games — passive income generation, offline earnings, upgrade progression, number formatting, and responsive mobile UI.