Technical requirements
Before you start:
- Download or clone the GitHub repository at https://github.com/PacktPublishing/C-Design-Patterns-with-Unity-First-Edition.
- Open the Ch_09_Starter project folder in Unity Hub.
- In Assets | Scenes, double-click on SampleScene.
The project for this chapter is a bare-bones infinite runner where your job is to move the player left and right to avoid the randomly generated objects being thrown at you (red for enemies, green for health). The UI panel in the upper left of the screen will eventually keep track of how good (or bad) you are at this game of white-boxed dodgeball, but for now, it’s keeping you at a steady 10 health.
As for the scripts:
BasePrefab.cs
is attached to both theTarget
andHealth
prefabs to move them forward when they are instantiated and destroy them when they hit the boundary collider behind the player.Player.cs
is attached to thePlayer
GameObject
in the Hierarchy...