Unity C# scripts

55 scripts that compile on Unity 2022.3 and newer. Every one is a single file with no package dependencies, MIT licensed, and readable in full before you download it.

44 scripts 4 2D-only 40 shared

2D

Sprites, tilemaps and Physics2D.

Platformer and top-down controllers, tile collision, sprite animation and 2D camera rigs.

51 scripts 11 3D-only 40 shared

3D

Rigidbodies, NavMesh and camera rigs.

First- and third-person controllers, agent pathfinding, physics interaction and orbit cameras.

By category

10 groups
11
Character controllers, jumping, dashing and camera follow.
4
Damage, health bars, invulnerability frames and respawn.
1
Music and SFX management that survives a scene load.
6
Menus, HUD elements, tooltips and screen transitions.
11
Object pooling, singletons, timers and the small helpers every project needs.
2
Item data and stacking, built on ScriptableObjects.
1
Branching conversation flow with typewriter output.
2
JSON save files, PlayerPrefs wrappers and load-on-start.
5
NavMesh agents, state machines, patrol routes and enemy behaviour.
12
Virtual joysticks, swipe and pinch gestures, device-safe input.

Recently added

Touch & Mobile Beginner

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.

  • 4-directional swipe detection
  • Configurable swipe threshold
  • Swipe speed and distance tracking

SwipeInputController.cs 3.4 KB Unity 2022.3+

Touch & Mobile Beginner

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.

  • Single and double tap detection
  • Configurable double-tap window
  • Tap position in screen and world space

TapInputHandler.cs 3.6 KB Unity 2022.3+

Touch & Mobile Intermediate

Touch Joystick

Virtual on-screen joystick for mobile touch input with dynamic or fixed positioning. Outputs normalized Vector2 direction suitable for character movement.

  • Dynamic or fixed joystick position
  • Configurable handle range
  • Normalized input output (-1 to 1)

TouchJoystick.cs 4.2 KB Unity 2022.3+

Touch & Mobile Beginner

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.

  • Press and release events
  • Hold detection with duration
  • Visual press feedback (scale)

TouchButton.cs 3.1 KB Unity 2022.3+