Technical requirements
To get started:
- Download or clone the GitHub repository at https://github.com/PacktPublishing/C-Design-Patterns-with-Unity-First-Edition.
- Open the Ch_16_Starter project folder in Unity Hub.
- In Assets > Scenes, double-click on SampleScene.
The starter project for this chapter is a top-down arena where you control a simple player capsule and try to collect all the red items in the scene. You can run forward and back using vertical key inputs, rotate using horizontal key inputs, and even jump if the mood strikes you.
As for the scripts:
PlayerBehavior.cs
is the client class for this example. Its only job is to hold a reference to aMovementController
instance (which we’ll switch later on) and call itsMove
andJump
methods inFixedUpdate
.MovementController.cs
is responsible for the default player locomotion – moving and rotating smoothly using the WASD or arrow keys and jumping using the Space...