🎮 Gameplay Setup (Overview)

This section explains how to configure the camera, slingshot, level manager, intro/showcase, UI & ammo, and enemies in the SlingshotSquad Template.


Requirements

  • Unity (URP/2D)

  • LeanTween (DentedPixel) in the project

  • An EventSystem in the scene (and Physics2DRaycaster on the Main Camera if the slingshot receives pointer input in the 2D world)


Slingshot Camera Controller

Controls manual pan, orthographic zoom, lock to the slingshot, projectile follow, and showcase focus on arbitrary points.

How to set up

  1. Select Main Camera and add SlingshotCameraController.

  2. Drag the slingshot Transform into slingshotFocus.

  3. Adjust movement limits to match your level bounds.

Key fields

  • Movement LimitsminX/maxX/minY/maxY World-space bounds for camera movement.

  • Manual PanmanualPanSpeed Drag speed for panning.

  • Zoom Settings

    • minOrthoSize / maxOrthoSize → zoom range

    • zoomStep / zoomDuration → step amount and tween time

  • Focus & Follow Settings

    • focusTweenDuration → tween time when locking to slingshot/targets

    • followLerpSpeed → smoothing when following projectile

  • References

    • slingshotFocus → focus point when calling LockToSlingshot()

Flow

  • Before launch: LockToSlingshot() recenters the camera and triggers StartGame() on the Level Manager.

  • During flight: Follow(projectile) tracks the projectile.

  • After impact/idle: ReturnToSlingshot() recenters and restores manual pan.

Tips If zoom “clips” at edges, either enlarge maxX/maxY or raise maxOrthoSize. Panning is disabled while SlingshotController.IsAiming is true.


Slingshot Controller

Handles aim, launch, trajectory dots, elastic band visuals, and integration with Level/Camera.

How to set up

  1. Create a SlingshotRoot GameObject and add SlingshotController.

  2. Assign launchPoint (an Empty at the sling muzzle).

  3. Assign directionDotPrefab (a small sprite/dot).

  4. If using pointer over world objects, add Physics2DRaycaster to the Camera and ensure clickable objects have Collider2D.

Key fields

  • Launch PointlaunchPoint, launchAudio

  • Direction DotsdirectionDotPrefab, dotCount, dotSpacing

  • Launch SettingsminForce, maxForce, maxPullDistance

  • Elastic BandelasticRenderer, elasticOffset, elasticThickness

  • Elastic ClampminVisualLength, maxVisualLength, stretchAxis

Launch flow

  1. PointerDown → spawns the next projectile from Level characterSequence and locks camera to the slingshot.

  2. Drag → updates projectile position, stretches the band, and shows trajectory dots.

  3. PointerUp → applies force (min–max), plays SFX, enables Skill, consumes active booster (if any), and calls Camera.Follow().

Tips If pointer events don’t fire, verify EventSystem, Physics2DRaycaster on Camera, and Collider2D on the slingshot target. Tune maxPullDistance together with minForce/maxForce.


Level Manager

Orchestrates the level: score, stars, win/lose, projectile sequence, camera return, and rewards.

How to set up

  1. Create LevelManager and add SlingshotLevelManager.

  2. Fill:

    • enemyList (drag AngryEnemy instances from the scene)

    • characterSequence (array of CharacterData in shot order)

    • ammoContainer (HUD reference)

    • defaultPopup (score popup)

The Level Manager queries LoadingManager (current map, ids, next map) and drives UIGameplay.

Key fields

  • Star ThresholdspointsFor1Star/2Star/3Star

  • Camera ReturnidleDamageTime (idle time with no damage to end the flight and decide outcome)

  • EventsOnLevelWin / OnLevelLose

Gameplay flow

  1. Boot → if the map unlocks a character, shows the unlock panel, then runs IntroShowcase.StartShowcase().

  2. ShotPopNextCharacter() returns the next CharacterData; HUD ammo updates accordingly.

  3. ScoringAddScore() increments points and updates stars.

  4. Win/Lose

    • Win: all enemies dead and idle ≥ idleDamageTime.

    • Lose: no ammo left and enemies still alive after idleDamageTime.

  5. Rewards/Progression → saves stars/highscore; applies XP/items; unlocks nextMap.

Useful hooks

  • AOE damage: ExplodeAt(pos, radius, dmg, vfx)

  • Boosters: FlagNextShotDoubleDamage(), AddExtraShot(CharacterData)

  • Score popups: ScorePopupSpawner.Spawn(...)


Intro Showcase

Moves the camera to a focusPoint, optionally changes zoom, waits, triggers enemy showcase (speech/audio), then returns to the slingshot.

How to set up

  1. Add IntroShowcase to a GameObject.

  2. Set focusPoint (an Empty at the target you want to highlight).

  3. Tune travelSpeed, showcaseZoomSize, staySeconds.

Flow

  • StartShowcase()

    • Computes travel time and calls SlingshotCameraController.LockToPoint(...)

    • Calls SlingshotLevelManager.TriggerEnemyShowcase()

    • After staySeconds, restores zoom (if changed) and ReturnToSling()


UI & Ammo

UIGameplay

Manages HUD (score), pause/resume, zoom buttons, boosters panel, return to home, skill hint, and the Active Booster HUD. It also shows the Unlock Character Panel with animation and spawns the character skill preview.

How to set up

  1. Use a Canvas with UIGameplay.

  2. Wire buttons (Pause/Resume/Zoom/Boosters/Home) and panels (Pause/Boosters/EndGame).

  3. Assign skillHint, Active Booster Root/Text, and Unlock panel fields.

Notes Without an AudioManager, the code falls back to AudioSource.PlayClipAtPoint. The Skill Hint is shown when the current projectile can use its skill and hidden on impact or after use.

AmmoContainer

Holds ammo icons and reorders them with a hop animation (LeanTween).

How to set up

  • Reference AmmoContainer in the Level Manager.

  • The Level Manager populates and removes icons automatically from the characterSequence.

Fields

  • spacing, hopHeight, hopTime → layout/animation

  • GetIconTransform(i) → used to display “unused” bonus popups over each icon


AngryEnemy (Impulse-Based Damage)

Enemies take damage based on collision impulse (mass × relative velocity), with thresholds and playable-graph animations.

How to set up

  1. Ensure Collider2D + Rigidbody2D + Animator are present.

  2. Tune maxHitPoints, damageThreshold, damagePerImpulse.

  3. In Showcase, enable showcaseEnabled and set speechBubble/showcaseClip if you want intro speech/audio.

Key fields

  • Self MultiplierselfImpulseScale (scales incoming damage)

  • ScorescoreOnDeath (points on death)

  • Playable Animations → presets idle/injured/win

  • VFX/SFXdeathVfx, deathSfx


CharacterProjectile (Shot Core)

Reads stats from CharacterData, plays Idle/Launch/Death animations, handles collision grace time, post-collision skill window, impact SFX/VFX, and booster visuals.

Flow

  1. SetupFromData(CharacterData) → pulls stats/FX/Skill; equips cosmetics using VisualMountPoints.

  2. OnLaunch() → enables physics, Trail/Stamp, Launch animation, and opens the skill window.

  3. OnCollisionEnter2D → respects grace/min speed, plays impact VFX/SFX, switches to Death animation, hides skill hint.

Key values (via CharacterData)

  • Damage: baseDamage, impulseBonusFactor, damageMultiplier

  • Despawn/Physics: despawnDelay, sleepVelocity

  • Collision: collisionGraceTime, minImpactSpeed

  • Scoring: bonusIfUnused

  • Skill: skillData (executed in TriggerSpecialAbility())

  • Visuals: trailRendererPrefab, stampTrailPrefab, impactVfx, launch/impact SFX


✅ Quick Scene Checklist

  1. Main CameraSlingshotCameraController (+ Physics2DRaycaster if using pointer over 2D world)

  2. SlingshotRootSlingshotController (launchPoint, dots, elastic)

  3. LevelManagerSlingshotLevelManager (enemies, characterSequence, ammoContainer, defaultPopup)

  4. UIUIGameplay (score, panels, buttons, skill hint, active booster HUD) + AmmoContainer

  5. IntroIntroShowcase with focusPoint

  6. Audio → optional AudioManager (fallback is built-in)

  7. LeanTween → present in project

  8. EventSystem → in scene


Suggested Defaults (Mobile)

  • Camera: minOrthoSize=5, maxOrthoSize=9, zoomStep=1, followLerpSpeed=5–7

  • Slingshot: maxPullDistance=3, minForce=2, maxForce=15, dotCount=10, dotSpacing=0.2

  • Level: idleDamageTime=3s; stars at 10k / 25k / 40k for baseline

  • Projectile (via CharacterData): collisionGraceTime≈0.2s, sleepVelocity≈0.3, minImpactSpeed≈0.5


Troubleshooting

  • Pointer not working: ensure EventSystem, Physics2DRaycaster on Camera, and Collider2D on the clickable object.

  • Camera won’t follow/return: verify slingshotFocus and camera event hooks.

  • No trajectory dots: check directionDotPrefab and dotCount > 0.

  • No audio: without AudioManager, playback falls back to AudioSource.PlayClipAtPoint.

  • Animations not playing: confirm Animator/presets assigned and no PlayableGraph errors in Console.

Last updated