Game development

Stage 2 · Lesson 5 of 7

Exposed variables and tuning

Programming for games

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

  • CourseFree
    Unity Learn: Junior Programmer Pathway

    Unity Technologies · Beginner

    Unity's official free C# pathway, with small playable projects in every unit

  • GuideFree
    Learn C#

    Microsoft · Beginner

    Microsoft's free C# lessons, for the language itself when Unity code feels unfamiliar

Practise

  • Free mentored exercises in C# and C++ to strengthen the language outside the engine

Keep handy

Also worth your time

Mark this stage as not done?