Stage 2 · Lesson 5 of 7
Exposed variables and tuning
is found by tweaking numbers while the game runs: speed, jump height, cooldowns, damage. So do not hard-code them. Make them that show up in the editor, where you can change them without touching code.
In use [SerializeField] fields, in @export variables, and in Unreal UPROPERTY(EditAnywhere) or variables. Then you or a designer can tune the game freely, and different enemies can share one script with different values.
Group related values, and give them sensible defaults and ranges. Later stages depend on this, especially game feel and balancing.
Common trapchanging values in play mode, finding the perfect numbers, then losing them all when you stop the game, because play mode changes are not saved.
A question to check yourself, an AI practice session and 1 cheat sheet entry come with the full roadmap. Unlock
Resources for this stage
Start with· follow one of these
- CourseFreeUnity Learn: Junior Programmer Pathway
Unity Technologies · Beginner
Unity's official free C# pathway, with small playable projects in every unit
- GuideFreeLearn C#
Microsoft · Beginner
Microsoft's free C# lessons, for the language itself when Unity code feels unfamiliar
Practise
Keep handy
Also worth your time
The exact order Unity calls Awake, Start, Update, FixedUpdate and the rest
- Game Programming PatternsGo deeper
Free book on the state, observer, component and other patterns games rely on