55 scripts found
Health & Combat Beginner

Health System

Reusable health component with damage, healing, invincibility frames, and events.

PlatformerFPS
public class HealthSystem : MonoBehaviour
{
    [SerializeField] private float maxHealth = 100f;
    public float HealthPercent => currentHealth / maxHealth;
    public void TakeDamage(float damage)
    public void Heal(float amount)
2022.3+ · 2.4 KB
Movement Beginner

2D Player Controller

Complete 2D character controller with smooth movement, variable-height jumping, and coyote time.

2D PlatformerGeneral
[RequireComponent(typeof(Rigidbody2D))]
public class PlayerController2D : MonoBehaviour
{
    [SerializeField] private float moveSpeed = 8f;
    [SerializeField] private float jumpForce = 16f;
    [SerializeField] private float coyoteTime = 0.15f;
2022.3+ · 3.2 KB
Movement Intermediate

3D Player Controller

First/third person character controller with smooth movement, jumping, and slope handling using C...

3D FPSRPG
[RequireComponent(typeof(CharacterController))]
public class PlayerController3D : MonoBehaviour
{
    [SerializeField] private float walkSpeed = 6f;
    [SerializeField] private float sprintSpeed = 10f;
    [SerializeField] private float jumpHeight = 1.5f;
2022.3+ · 4.1 KB
Movement Beginner

Smooth Camera Follow 2D

Smooth camera follow with offset, dead zone, and look-ahead for 2D games.

2D PlatformerGeneral
public class CameraFollow2D : MonoBehaviour
{
    [SerializeField] private Transform target;
    [SerializeField] private Vector3 offset = new Vector3(0f, 1f, -10f);
    [SerializeField] private float smoothSpeed = 8f;
2022.3+ · 1.8 KB
Utilities Intermediate

Generic Singleton

Thread-safe, persistent singleton base class for managers like AudioManager, GameManager, etc.

General
public abstract class Singleton<T> : MonoBehaviour where T : MonoBehaviour
{
    private static T instance;
    public static T Instance
    {
        get { ... }
    }
2022.3+ · 1.2 KB
Movement Beginner

First Person Camera

First person mouse look camera with sensitivity, vertical clamp, and cursor lock. Plug into any F...

3D FPSHorror
public class FirstPersonCamera : MonoBehaviour
{
    [SerializeField] private float mouseSensitivity = 2f;
    [SerializeField] private float minVerticalAngle = -90f;
    [SerializeField] private float maxVerticalAngle = 90f;
2022.3+ · 2.4 KB
Audio Intermediate

Audio Manager

Complete audio manager with music crossfade, SFX pooling, volume control, and persistence.

General
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)
2022.3+ · 4.5 KB
Utilities Intermediate

Object Pool

Generic object pooling system to reduce garbage collection. Perfect for bullets, particles, and e...

FPSGeneral
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)
2022.3+ · 2.1 KB
Movement Intermediate

Third Person Camera

Orbit camera with collision detection, zoom, and vertical angle limits. Ideal for action-adventur...

3D RPGGeneral
public class ThirdPersonCamera : MonoBehaviour
{
    [SerializeField] private Transform target;
    [SerializeField] private float defaultDistance = 5f;
    [SerializeField] private float rotationSpeed = 5f;
2022.3+ · 3.6 KB
UI Beginner

Health Bar UI

World-space or screen-space health bar with smooth fill, color gradient, and damage flash. Attach...

RPGFPS
public class HealthBarUI : MonoBehaviour
{
    [SerializeField] private float smoothSpeed = 5f;
    [SerializeField] private Gradient colorGradient;
    public void SetHealth(float current, float max)
2022.3+ · 2.4 KB
Utilities Beginner

Scene Manager

Async scene loading with loading screen, progress bar, and minimum load time. Clean transitions b...

General
public class SceneLoader : MonoBehaviour
{
    public static SceneLoader Instance { get; private set; }
    public void LoadScene(string sceneName)
    private IEnumerator LoadSceneAsync(string sceneName)
2022.3+ · 2.5 KB
AI & Pathfinding Beginner

Enemy Chase AI

Enemy AI that detects the player within radius, chases with line-of-sight, and returns to patrol ...

RPGFPS
public class EnemyChaseAI : MonoBehaviour
{
    [SerializeField] private float detectionRadius = 10f;
    [SerializeField] private float fieldOfView = 120f;
    [SerializeField] private float chaseSpeed = 5f;
2022.3+ · 2.5 KB
Health & Combat Intermediate

Weapon System

ScriptableObject-driven weapon system with melee and ranged attacks, cooldowns, ammo, and damage ...

FPSRPG
public class WeaponSystem : MonoBehaviour
{
    [SerializeField] private WeaponData currentWeapon;
    public void Attack()
    public void EquipWeapon(WeaponData weapon)
2022.3+ · 3.8 KB
Movement Intermediate

2D Platformer Mechanics

Wall jump, wall slide, dash, and double jump mechanics for 2D platformers. Drop-in extension for ...

2D Platformer
[RequireComponent(typeof(Rigidbody2D))]
public class PlatformerMechanics2D : MonoBehaviour
{
    [SerializeField] private bool enableWallJump = true;
    [SerializeField] private bool enableDoubleJump = true;
    [SerializeField] private bool enableDash = true;
2022.3+ · 3.5 KB
Movement Intermediate

2D Player Controller Pro

PRO

Advanced 2D character controller with wall jump, wall slide, dash, double jump, ledge grab, and m...

2D Platformer
[RequireComponent(typeof(Rigidbody2D))]
public class PlayerController2DPro : MonoBehaviour
{
    [SerializeField] private float wallSlideSpeed = 2f;
    [SerializeField] private float wallJumpForce = 14f;
    [SerializeField] private float dashSpeed = 24f;
2022.3+ · 6.2 KB
Movement Intermediate

3D Player Controller Pro

PRO

Advanced 3D character controller with crouch, slide, ladder climbing, swimming, stamina system, a...

3D FPSRPG
[RequireComponent(typeof(CharacterController))]
public class PlayerController3DPro : MonoBehaviour
{
    [SerializeField] private float crouchSpeed = 2.5f;
    [SerializeField] private float slideSpeed = 14f;
    [SerializeField] private float climbSpeed = 4f;
2022.3+ · 7.0 KB
UI Beginner

Screen Fader

Simple screen fade-in/fade-out with configurable color and duration. Great for scene transitions.

General
public class ScreenFader : MonoBehaviour
{
    public static ScreenFader Instance { get; private set; }
    public Coroutine FadeIn(float duration = -1f)
    public Coroutine FadeOut(float duration = -1f)
2022.3+ · 1.6 KB
UI Beginner

Damage Popup

Floating damage numbers that animate upward and fade out. Supports critical hits, healing, and cu...

RPGGeneral
public class DamagePopup : MonoBehaviour
{
    public static DamagePopup Create(
        Vector3 position, float amount,
        bool isCritical = false, bool isHeal = false)
2022.3+ · 2.6 KB
Utilities Beginner

Camera Shake

Perlin noise camera shake with magnitude, frequency, and duration. Trigger from explosions, impac...

FPSPlatformer
public class CameraShake : MonoBehaviour
{
    public static CameraShake Instance { get; private set; }
    [SerializeField] private float defaultMagnitude = 0.15f;
    [SerializeField] private float frequency = 25f;
    public void Shake(float duration, float magnitude)
2022.3+ · 1.8 KB
Utilities Beginner

Interaction System

Raycast-based interaction with prompt UI, hold-to-interact option, and IInteractable interface. P...

RPGHorror
public interface IInteractable
{
    string InteractionPrompt { get; }
    void Interact(GameObject interactor);
}
2022.3+ · 2.8 KB
AI & Pathfinding Beginner

Waypoint Patrol AI

Enemy patrol between waypoints with configurable speed, wait times, and patrol patterns (loop, pi...

RPGRTS
public class WaypointPatrol : MonoBehaviour
{
    public enum PatrolMode { Loop, PingPong, Random }
    [SerializeField] private Transform[] waypoints;
    [SerializeField] private float moveSpeed = 3f;
    [SerializeField] private PatrolMode patrolMode = PatrolMode.Loop;
2022.3+ · 2.3 KB
Inventory Beginner

Simple Inventory

Lightweight list-based inventory for prototypes. Add, remove, and check items without UI complexity.

RPGGeneral
public class SimpleInventory : MonoBehaviour
{
    [SerializeField] private int maxSlots = 20;
    public int AddItem(string itemId, int quantity = 1)
    public int RemoveItem(string itemId, int quantity = 1)
2022.3+ · 1.9 KB
Save & Load Intermediate

JSON Save Utility

File-based JSON save/load utility. Save any serializable class to persistent storage with one met...

RPGGeneral
public static class JsonSaveUtility
{
    public static void Save<T>(T data, string fileName)
    public static T Load<T>(string fileName)
    public static bool Exists(string fileName)
2022.3+ · 2.0 KB
Health & Combat Beginner

Projectile System

Configurable projectile with speed, damage, lifetime, and optional homing. Integrates with Object...

FPSGeneral
public class Projectile : MonoBehaviour, IPoolable
{
    [SerializeField] private float speed = 20f;
    [SerializeField] private float damage = 10f;
    [SerializeField] private float lifetime = 5f;
    private void OnTriggerEnter(Collider other)
2022.3+ · 2.2 KB
Utilities Intermediate

Quest System

Lightweight quest tracker with ScriptableObject definitions, objectives, progress tracking, and r...

RPG
public class QuestSystem : MonoBehaviour
{
    public static QuestSystem Instance { get; private set; }
    public bool AcceptQuest(QuestData quest)
    public void ReportProgress(string objectiveId, int amount = 1)
2022.3+ · 3.4 KB
Utilities Intermediate

Input Manager

Clean wrapper around Unity's new Input System with action map switching, rebinding support, and i...

General
public class InputManager : MonoBehaviour
{
    public static InputManager Instance { get; private set; }
    public bool WasPressed(string actionName)
    public void StartRebind(string actionName)
2022.3+ · 2.8 KB
Movement Intermediate

First Person Camera Pro

PRO

Advanced FPS camera with head bob, weapon sway, lean, recoil system, and FOV zoom for immersive f...

3D FPSHorror
public class FirstPersonCameraPro : MonoBehaviour
{
    [SerializeField] private bool enableHeadBob = true;
    [SerializeField] private bool enableLean = true;
    [SerializeField] private float zoomFOV = 40f;
    public void AddRecoil(float verticalRecoil, float horizontalRecoil)
2022.3+ · 5.5 KB
Utilities Beginner

Timer / Countdown

Versatile timer with countdown, stopwatch, and repeating modes. Formatted time display and UnityE...

PuzzleGeneral
public class Timer : MonoBehaviour
{
    public enum TimerMode { Countdown, Stopwatch, Repeating }
    public UnityEvent OnTimerComplete;
    public UnityEvent<float> OnTimerTick;
    public void StartTimer()
2022.3+ · 2.1 KB
AI & Pathfinding Intermediate

NavMesh Click-to-Move

Click-to-move character controller using NavMeshAgent. Click anywhere to navigate, with destinati...

3D RTSRPG
[RequireComponent(typeof(NavMeshAgent))]
public class NavMeshClickToMove : MonoBehaviour
{
    private NavMeshAgent agent;
    public void MoveTo(Vector3 destination)
2022.3+ · 2.1 KB
Inventory Beginner

Pickup / Collectible

Collectible item with bobbing animation, rotation, magnet pull, and event callbacks for coins, he...

PlatformerRPG
public class Collectible : MonoBehaviour
{
    [SerializeField] private int value = 1;
    [SerializeField] private string itemId = "coin";
    private void OnTriggerEnter(Collider other)
    private void OnTriggerEnter2D(Collider2D other)
2022.3+ · 2.0 KB
Dialogue Beginner

Dialogue Trigger

Simple NPC dialogue with sequential messages, typewriter effect, and input to advance. No branchi...

RPGGeneral
public class DialogueTrigger : MonoBehaviour
{
    [SerializeField] private string speakerName = "NPC";
    [SerializeField] [TextArea(2, 5)] private string[] messages;
    public void StartDialogue()
2022.3+ · 2.5 KB
Save & Load Beginner

PlayerPrefs Save Helper

Type-safe PlayerPrefs wrapper with support for bool, Vector3, Color, and any serializable object ...

General
public static class SaveHelper
{
    public static void SetObject<T>(string key, T obj)
    public static T GetObject<T>(string key, T defaultValue = default)
    public static void Save() => PlayerPrefs.Save();
2022.3+ · 1.6 KB
Utilities Intermediate

Wave Spawner

Wave-based enemy spawner with configurable wave definitions, spawn points, delays, and wave compl...

FPSRTS
public class WaveSpawner : MonoBehaviour
{
    [System.Serializable]
    public class Wave
    {
        public string waveName = "Wave";
        public EnemySpawn[] enemies;
    }
    private IEnumerator SpawnWave()
2022.3+ · 3.0 KB
Movement Beginner

Top-Down Camera

RTS/strategy camera with WASD panning, edge scrolling, scroll wheel zoom, and optional target fol...

3D RTSRPG
public class TopDownCamera : MonoBehaviour
{
    [SerializeField] private float panSpeed = 20f;
    [SerializeField] private bool enableEdgeScroll = true;
    [SerializeField] private float zoomSpeed = 5f;
2022.3+ · 2.6 KB
UI Intermediate

Tooltip System

Dynamic mouse-following tooltip that auto-positions to stay on screen. Supports rich text and cus...

RPGGeneral
public class TooltipSystem : MonoBehaviour
{
    public static TooltipSystem Instance { get; private set; }
    public static void Show(string header, string body = "")
    public static void Hide()
2022.3+ · 2.5 KB
UI Intermediate

Minimap System

Render texture minimap with player icon, enemy blips, objective markers, and zoom control.

RTSRPG
public class MinimapSystem : MonoBehaviour
{
    public static MinimapSystem Instance { get; private set; }
    public static void RegisterIcon(Transform target, Color color, float scale = 1f)
    public void ZoomIn()
    public void ZoomOut()
2022.3+ · 3.2 KB
AI & Pathfinding Advanced

A* Grid Pathfinding

Grid-based A* pathfinding without NavMesh. Supports diagonal movement, weighted nodes, and debug ...

RTSRPG
public class AStarPathfinding : MonoBehaviour
{
    private class Node
    {
        public int x, y;
        public bool walkable;
        public float fCost => gCost + hCost;
    }
    public List<Vector3> FindPath(Vector3 startPos, Vector3 endPos)
2022.3+ · 4.2 KB
Movement Intermediate

Third Person Camera Pro

PRO

Advanced orbit camera with lock-on targeting, shoulder swap, cinematic mode, and swappable camera...

3D RPGGeneral
public class ThirdPersonCameraPro : MonoBehaviour
{
    [SerializeField] private float collisionRadius = 0.25f;
    [SerializeField] private bool enableLockOn = true;
    [SerializeField] private KeyCode shoulderSwapKey = KeyCode.V;
    public void SetProfile(string profileName)
2022.3+ · 6.5 KB
UI Intermediate

Health Bar UI Pro

PRO

Advanced health bar with delayed damage indicator, shield overlay, boss mode with phase markers, ...

RPGFPS
public class HealthBarUIPro : MonoBehaviour
{
    [SerializeField] private Image delayedFillImage;
    [SerializeField] private bool showSegments;
    [SerializeField] private int segmentCount = 5;
    public void SetHealth(float current, float max)
2022.3+ · 5.2 KB
Health & Combat Intermediate

Weapon System Pro

PRO

Advanced ScriptableObject weapon system with combo chains, weapon switching, damage types, critic...

FPS
public class WeaponSystemPro : MonoBehaviour
{
    [SerializeField] private List<WeaponDataPro> weaponInventory;
    public void EquipWeapon(int index)
    public void Reload()
    public bool AddModifier(WeaponModifier mod)
2022.3+ · 7.2 KB
Touch & Mobile Beginner

Swipe Input Controller

Detects touch swipes in four directions with configurable thresholds and dead zones. Fires UnityE...

MobileHyper Casual
public enum SwipeDirection { None, Up, Down, Left, Right }
[SerializeField] private float minSwipeDistance = 50f;
public UnityEvent onSwipeUp;
2022.3+ · 3.4 KB
Touch & Mobile Beginner

Tap Input Handler

Handles single tap, double tap, and long press gestures with configurable timing. Provides tap po...

MobileHyper Casual
public UnityEvent<Vector2> onSingleTap;
public UnityEvent<Vector2> onDoubleTap;
public UnityEvent<Vector2> onLongPress;
2022.3+ · 3.6 KB
Touch & Mobile Intermediate

Touch Joystick

Virtual on-screen joystick for mobile touch input with dynamic or fixed positioning. Outputs norm...

MobilePlatformer
public class TouchJoystick : MonoBehaviour, IPointerDownHandler, IDragHandler, IPointerUpHandler
{
    public Vector2 InputDirection { get; private set; }
    [SerializeField] private float handleRange = 50f;
2022.3+ · 4.2 KB
Touch & Mobile Intermediate

Endless Runner Controller

Complete endless runner character controller with auto-forward movement, lane switching, jump and...

MobileHyper Casual
[RequireComponent(typeof(CharacterController))]
public class EndlessRunnerController : MonoBehaviour
{
    [SerializeField] private float laneWidth = 2.5f;
    [SerializeField] private float jumpForce = 10f;
2022.3+ · 4.8 KB
Touch & Mobile Beginner

Score Manager

Complete score management system with high score persistence, combo multipliers with decay, and s...

Hyper CasualMobile
public static ScoreManager Instance { get; private set; }
public void AddScore(int points)
{
    int earnedPoints = points * ComboMultiplier;
2022.3+ · 3.3 KB
Utilities Intermediate

Day/Night Cycle

Configurable day/night cycle with directional light rotation, color gradient, and time-of-day eve...

3D RPGGeneral
public class DayNightCycle : MonoBehaviour
{
    [SerializeField] [Range(0f, 24f)] private float timeOfDay = 12f;
    [SerializeField] private Light directionalLight;
    [SerializeField] private Gradient sunColor;
2022.3+ · 2.6 KB
Utilities Advanced

Procedural Dungeon Generator

BSP-based dungeon generator that creates random room layouts with corridors, doors, and spawn poi...

RPG
public class DungeonGenerator : MonoBehaviour
{
    [SerializeField] private int minRoomSize = 6;
    [SerializeField] private int maxRoomSize = 15;
    [SerializeField] private int corridorWidth = 2;
    public void Generate()
2022.3+ · 4.0 KB
AI & Pathfinding Intermediate

Waypoint Patrol AI Pro

PRO

Advanced patrol AI with NavMesh pathfinding, player detection with awareness meter, alert states,...

RPGRTS
[RequireComponent(typeof(NavMeshAgent))]
public class WaypointPatrolPro : MonoBehaviour
{
    public enum AIState { Patrol, Alert, Investigate, Return }
    [SerializeField] private float awarenessRate = 1.5f;
    [SerializeField] private float alertCallRange = 15f;
2022.3+ · 6.0 KB
Touch & Mobile Beginner

Touch Button

Mobile-friendly UI button with press, release, and hold events plus visual feedback. Includes con...

MobileGeneral
public class TouchButton : MonoBehaviour, IPointerDownHandler, IPointerUpHandler
{
    public UnityEvent onPressed;
    [SerializeField] private float pressedScale = 0.9f;
2022.3+ · 3.1 KB
Touch & Mobile Intermediate

Pinch-to-Zoom Camera

Smooth pinch-to-zoom camera control for mobile devices supporting both orthographic and perspecti...

MobileRTS
public class PinchToZoomCamera : MonoBehaviour
{
    [SerializeField] private float zoomSpeed = 0.5f;
    float currentDistance = Vector2.Distance(touch0.position, touch1.position);
2022.3+ · 3.0 KB
Touch & Mobile Beginner

Stack Mechanic

Tap-to-place stacking game mechanic where a moving block must be stopped to align with the previo...

3D Hyper CasualMobile
public class StackMechanic : MonoBehaviour
{
    [SerializeField] private float perfectThreshold = 0.05f;
    float overhang = currentPosX - previousBlockPosX;
2022.3+ · 4.1 KB
Touch & Mobile Intermediate

Idle Income Generator

Passive income system for idle/clicker games with offline earnings calculation, upgrade scaling, ...

MobileGeneral
public double IncomePerSecond => CalculateIncome();
public static string FormatNumber(double number)
{
    if (number >= 1e12) return (number / 1e12).ToString("F1") + "T";
2022.3+ · 4.5 KB
Touch & Mobile Beginner

Mobile Safe Area Handler

Automatically adjusts UI RectTransform to respect device safe areas on notched phones and tablets...

MobileGeneral
[RequireComponent(typeof(RectTransform))]
public class MobileSafeArea : MonoBehaviour
{
    Rect safeArea = Screen.safeArea;
    anchorMin.x /= Screen.width;
2022.3+ · 2.8 KB
Touch & Mobile Intermediate

Gyroscope Camera Controller

Controls camera rotation using the device gyroscope sensor with smoothing and sensitivity setting...

3D MobileFPS
public class GyroscopeCameraController : MonoBehaviour
{
    [SerializeField] private float sensitivity = 1f;
    Quaternion convertedRotation = ConvertGyroRotation(rawGyro);
2022.3+ · 3.5 KB
Touch & Mobile Intermediate

Mobile Responsive UI Scaler

Dynamically adjusts UI scaling based on device aspect ratio, DPI, and orientation. Works with Uni...

MobileGeneral
[RequireComponent(typeof(CanvasScaler))]
public class MobileResponsiveScaler : MonoBehaviour
{
    [SerializeField] private Vector2 referenceResolution = new Vector2(1080, 1920);
    canvasScaler.matchWidthOrHeight = match;
2022.3+ · 4.0 KB