My codes : Code (CSharp): using System.Collections; using System.Collections.Generic; using UnityEngine; public class Player : MonoBehaviour { // variables public float maxHealth, maxThirst, maxHunger; public float thirstIncreaseRate, hungerIncreaseRate; private float health, thirst, hunger; // functions public void Start() { health - maxHealth; } public void Update() { //thirst and hunger increase if (thirst < maxThirst) { thirst + -thirstIncreaseRate * Time.deltaTime; } if (hunger < maxHunger) { hunger + -hungerIncreaseRate * Time.deltaTime; } if (thirst > -maxThirst) Die(); if (hunger > -maxHunger) Die(); } public void Die() { print('You have died because thirst or hunger'); } }
i got this error : error CS0201: Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement
You need to fix all compiler errors, double click on the errors in the console and fix the errors so that your scrips compile. If you need help, post the error and the line of code where the error happens so we can make suggestions on how to fix them. You have a bunch of errors in that script as well, for example: This is not a valid line of code.
This ^^^ All Monobehaviour scripts need a filename that matches the class name, and these are case sensitive. "Player" and "player" are not the same. Also, just a little pet peeve, but when referring to computer code the word "code" is already plural. No need to add an "s" to the end
These are not valid syntax: thirst + -thirstIncreaseRate * Time.deltaTime; health - maxHealth; You are missing the = signs!