Skip to content

Instantly share code, notes, and snippets.

@unikiddy
Created June 15, 2018 11:50
Unitidtessasdqasd
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");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment