Your complete step-by-step walkthrough — follow at your own pace, tick every box
float speed = 5.0f; from inside Update().speed outside of Update and added the keyword public. Now speed is a class-level variable (also called a field) — it exists for the entire life of the script, not just one frame.public, Unity automatically shows it in the Inspector. You can now change speed without editing code.= 5.0f, if you set it to 8 in the Inspector, it stays at 8. The code value is just the default.public before float? Did you save the script?float speed = 5.0f; from inside Update(). You should NOT have it in both places.public float speed line, add these new variables:
+ sign joins text together (this is called concatenation). So "Player: " + playerName becomes "Player: Hero" in the Console.public int score = 0; — track the player's scorepublic float gravity = -9.8f; — gravity strengthpublic bool hasShield = false; — does player have a shield?public string weaponName = "Sword"; — current weaponpublic before the type. Also check: did you put it ABOVE Start(), not inside a function?"Hello", not 'Hello' or just Hello.5.0f, not 5.0. The f tells C# this is a float, not a double.verticalSpeed instead of speed:
> and < correctly. Don't mix them up!Only if you've finished Sections 1-4.
public float sprintMultiplier = 2.0f; variable. When the player holds Left Shift, multiply speed by the sprint multiplier:
currentSpeed instead of speed in your Translate.
timePlayed += Time.deltaTime; — this counts seconds played.
[SerializeField]:
int totalScore, int highScore, bool isGameOver, string levelName. Attach it to an empty GameObject called "GameManager". No code in Start/Update needed — just declare the variables.