Unit 3 — The Turret

The first enemy that shoots. Distance checks, Instantiated projectiles, and the cooldown — the single most reused pattern of the year — all arrive in four lessons that end in a tuned, playtested threat.

Lessons

IDTitleWhat you build / learn
3.1The Turret: Distance & the Detection RadiusVector3.Distance as a region in space
3.2Projectiles: Instantiate, Fire, Destroyspawn, aim, rotate, travel, die
3.3Fire Rate: Cooldowns & TimeTime.time, lastAttackTime, the compound conditional
3.4Projectile Damage, Tuning & Playtestgiving the bullet a collider, then tuning four knobs

Concepts this unit owns

The cooldown/timestamp pattern is taught here and reused by enemy contact damage, your own swing, jump mercies, and turn gates. CED: AAP-1 (procedural abstraction: AttackPlayer hides the fire path), AAP-2 (calling procedures), AAP-3 (logic in compound conditionals).

← Unit 2 All units Unit 4 →