Quantcast
Channel: Active questions tagged crash - Stack Overflow
Viewing all articles
Browse latest Browse all 7196

When i use the hungerPlus function it crashes

$
0
0

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


Viewing all articles
Browse latest Browse all 7196

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>