Time for action – setting the Lives for Player
The Lives remaining for Player will be stored in a variable in GameData
. We don't want it in PlayerControl
because this information has no bearing on controlling Player.
- As shown in the following
GameData
screenshot, add lines 10 and 11: - As shown in the following
SetupState
screenshot, insert the section of code in the red box:
What just happened?
Let us analyze the code shown in the preceding screenshots:
In GameData
:
Line 11: public int playerLives;
- The variable
playerLives
holds the remaining Lives available ...
Get Learning C# by Developing Games with Unity 3D Beginner's Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.