- Home /
Question by
CristiGAMING · Nov 01, 2021 at 03:08 PM ·
crash
Why is this crashing my game
This code crashed my game:
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);
}
}
Comment
Is there a crash report or does it just freeze? Could you please describe the scenario better? What's the use case, which gameObject is this script attached to, what is the intention of this action?
Your answer
Follow this Question
Related Questions
Player crash during the loading of a level 1 Answer
my project broken help me 1 Answer
LoadLevelAsync Causes Unity to Crash? 1 Answer
Unity 4.2 crash when editor recompiles project 1 Answer
Unity 4.2 IOS Exception Handling 0 Answers