Hey Guys I have a huge problem. first of sorry for the german names of my variables.
whenever I run this:
using UnityEngine;
using System.Collections;
public class palme : MonoBehaviour {
public float[,] m_bomben;
public bool m_wurfBereit = true;
public int m_bombenMenge = 1;
public float m_laengeBlock = 1.0f;
public int m_laengeMapInBloecken = 11;
public int m_breiteMapInBloecken = 11;
System.Random rng = new System.Random();
public float m_zufallszahlen(int i)
{
return (rng.Next(-1 * (i / 2), (i / 2))) * m_laengeBlock;
}
void Start ()
{
float[,] m_bomben = new float[m_bombenMenge, 2];
}
void Update ()
{
if (m_wurfBereit)
{
for (int i = 0; i < m_bombenMenge; i++)
{
Debug.Log("i ist " + i);
m_bomben[i, 0] = m_zufallszahlen(m_laengeMapInBloecken);
m_bomben[i, 1] = m_zufallszahlen(m_breiteMapInBloecken);
Debug.Log(m_bomben[i,1]);
}
}
m_wurfBereit = false;
}
}
Unity gives me the Error
“NullReferenceException: Object reference not set to an instance of an object”
But I just don’t know why !?
It some how seems to be the Array that messes up.
PS.: I’m pretty new to C# and Unity so there might just be weird coding none would write