This code crashes my game when I use the hungerPlus function:
using System.Collections;using System.Collections.Generic;using UnityEngine;public class Food : MonoBehaviour{ public PlayerController hungerManager; public float hungerValue; float healthValue; private void Update() { if (Input.GetKeyDown(KeyCode.Mouse0)) { hungerplus(); } } public void hungerplus() { healthValue = hungerValue / 2; hungerManager.hunger += hungerValue; hungerManager.health += healthValue; Destroy(gameObject); }}
What should i do for this to not crash everything. What part of this code makes the code leak memory