Unity C# scripts
55 single-file scripts, MIT licensed. Every page shows the Inspector fields the script adds, its public API, what it needs in your scene, and the Unity version it targets.
55 scripts 40 work in 2D and 3D 4 2D only 11 3D only 51 on Unity 2022.3+, 4 need Unity 6
Touch & Mobile 12
Free Unity C# mobile scripts: virtual joystick, swipe and tap input, pinch-to-zoom, safe-area handling for notched phones, and hyper-casual mechanics.
- Swipe Input Controller Detects touch swipes in four directions with configurable thresholds and dead zones. Fires UnityEvents for each swipe direction with speed and distance tracking.
- Tap Input Handler Handles single tap, double tap, and long press gestures with configurable timing. Provides tap position in both screen and world space coordinates.
- Touch Joystick Virtual on-screen joystick for mobile touch input with dynamic or fixed positioning. Outputs normalized Vector2 direction suitable for character movement.
- Endless Runner Controller Complete endless runner character controller with auto-forward movement, lane switching, jump and slide mechanics. Speed increases over time with death and restart handling.
- Score Manager Complete score management system with high score persistence, combo multipliers with decay, and score change events. Uses singleton pattern for easy global access.
- Touch Button Mobile-friendly UI button with press, release, and hold events plus visual feedback. Includes configurable cooldown and hold duration tracking for responsive touch controls.
- Pinch-to-Zoom Camera Smooth pinch-to-zoom camera control for mobile devices supporting both orthographic and perspective cameras. Features configurable zoom limits and optional smoothing.
- Stack Mechanic Tap-to-place stacking mechanic: stop the moving block over the last one. Trims the overhang, detects perfect placements and tracks stack height.
- Idle Income Generator Passive income system for idle/clicker games with offline earnings calculation, upgrade scaling, and prestige mechanics. Handles large numbers with K/M/B/T formatting.
- Mobile Safe Area Handler Fits a UI RectTransform to the device safe area on notched phones and tablets, and updates on orientation changes, on iOS and Android.
- Gyroscope Camera Controller Rotates the camera with the device gyroscope, with smoothing, sensitivity, calibration, axis locking and a fallback for devices without a gyroscope.
- Mobile Responsive UI Scaler Adjusts UI scale to the device's aspect ratio, DPI and orientation alongside CanvasScaler, so fonts stay readable and layouts hold on every phone.
Movement 11
Free Unity C# movement scripts: 2D and 3D player controllers, first-person, third-person and top-down cameras, wall jumps and dashes. MIT licensed.
- 2D Player ControllerUnity 6 Complete 2D character controller with smooth movement, variable-height jumping, and coyote time.
- 3D Player Controller First/third person character controller with smooth movement, jumping, and slope handling using CharacterController.
- Smooth Camera Follow 2D Smooth camera follow with offset, dead zone, and look-ahead for 2D games.
- First Person Camera First person mouse look camera with sensitivity, vertical clamp, and cursor lock. Plug into any FPS or exploration game.
- Third Person Camera Orbit camera with collision detection, zoom, and vertical angle limits. Ideal for action-adventure and RPG games.
- 2D Platformer MechanicsUnity 6 Wall jump, wall slide, dash, and double jump mechanics for 2D platformers. Drop-in extension for the 2D Player Controller.
- 2D Player Controller ProProUnity 6 Advanced 2D character controller with wall jump, wall slide, dash, double jump, ledge grab, and moving platform support.
- 3D Player Controller ProPro Advanced 3D character controller with crouch, slide, ladder climbing, swimming, stamina system, and footstep audio.
- First Person Camera ProPro Advanced FPS camera with head bob, weapon sway, lean, recoil system, and FOV zoom for immersive first person gameplay.
- Top-Down Camera RTS/strategy camera with WASD panning, edge scrolling, scroll wheel zoom, and optional target follow.
- Third Person Camera ProPro Advanced orbit camera with lock-on targeting, shoulder swap, cinematic mode, and swappable camera profiles for versatile third person gameplay.
Utilities 11
Free Unity C# utility scripts: object pooling, a generic singleton, async scene loading, timers, camera shake, interaction, wave spawning and quests.
- Generic Singleton Thread-safe, persistent singleton base class for managers like AudioManager, GameManager, etc.
- Object Pool Generic object pooling system to reduce garbage collection. Perfect for bullets, particles, and enemies.
- Scene Manager Async scene loading with loading screen, progress bar, and minimum load time. Clean transitions between levels.
- Camera Shake Perlin noise camera shake with magnitude, frequency, and duration. Trigger from explosions, impacts, or any event.
- Interaction System Raycast-based interaction with prompt UI, hold-to-interact option, and IInteractable interface. Press E to interact with anything.
- Quest System Lightweight quest tracker with ScriptableObject definitions, objectives, progress tracking, and reward callbacks.
- Input Manager Rebindable action layer over Unity's legacy Input class: named actions, runtime key rebinding saved to PlayerPrefs, and pressed and released queries.
- Timer / Countdown Versatile timer with countdown, stopwatch, and repeating modes. Formatted time display and UnityEvent callbacks.
- Wave Spawner Wave-based enemy spawner with configurable wave definitions, spawn points, delays, and wave completion callbacks.
- Day/Night Cycle Configurable day/night cycle with directional light rotation, color gradient, and time-of-day event triggers.
- Procedural Dungeon Generator BSP-based dungeon generator that creates random room layouts with corridors, doors, and spawn points.
UI 6
Free Unity C# UI scripts: health bars with smooth fill, floating damage numbers, screen fades, tooltips and a render-texture minimap.
- Health Bar UI World-space or screen-space health bar with smooth fill, color gradient, and damage flash. Attach to enemies or use as HUD.
- Screen Fader Simple screen fade-in/fade-out with configurable color and duration. Great for scene transitions.
- Damage Popup Floating damage numbers that animate upward and fade out. Supports critical hits, healing, and custom colors.
- Tooltip System Dynamic mouse-following tooltip that auto-positions to stay on screen. Supports rich text and custom layouts.
- Minimap System Render texture minimap with player icon, enemy blips, objective markers, and zoom control.
- Health Bar UI ProPro Advanced health bar with delayed damage indicator, shield overlay, boss mode with phase markers, and segmented health display.
AI & Pathfinding 5
Free Unity C# enemy AI scripts: waypoint patrols, chase with line of sight, NavMesh click-to-move, and grid A* pathfinding without a NavMesh.
- Enemy Chase AI Enemy AI that detects the player within radius, chases with line-of-sight, and returns to patrol when player escapes.
- Waypoint Patrol AI Enemy patrol between waypoints with configurable speed, wait times, and patrol patterns (loop, ping-pong, random).
- NavMesh Click-to-Move Click-to-move character controller using NavMeshAgent. Click anywhere to navigate, with destination marker and path line.
- A* Grid Pathfinding Grid-based A* pathfinding without NavMesh. Supports diagonal movement, weighted nodes, and debug visualization.
- Waypoint Patrol AI ProPro Advanced patrol AI with NavMesh pathfinding, player detection with awareness meter, alert states, group coordination, and patrol schedules.
Health & Combat 4
Free Unity C# health and combat scripts: a reusable health component with invincibility frames, projectiles with homing, and ScriptableObject weapons.
- Health System Reusable health component with damage, healing, invincibility frames, and events.
- Weapon System ScriptableObject-driven weapon system with melee and ranged attacks, cooldowns, ammo, and damage calculation.
- Projectile System Configurable projectile with speed, damage, lifetime, and optional homing. Integrates with Object Pool for zero-alloc shooting.
- Weapon System ProProUnity 6 Advanced ScriptableObject weapon system with combo chains, weapon switching, damage types, critical hits, and upgrade modifier slots.
Inventory 2
Free Unity C# inventory scripts: collectible pickups with bobbing and magnet pull, and a lightweight list-based inventory for prototypes.
Save & Load 2
Free Unity C# save scripts: a type-safe PlayerPrefs wrapper for settings, and a JSON save utility that writes any serializable class to disk.
Audio 1
A free Unity C# audio manager with music crossfading, pooled sound effects and separate music and SFX volume, kept alive across scene loads.
Dialogue 1
A free Unity C# dialogue trigger for NPCs: sequential lines, a typewriter text effect and a key press to advance. No dialogue framework needed.