C# Array Question

I can’t get this little snipped of code to work so I obviously screwed up something pretty simple. This is the line.

		float[] levelmult = [5.0, 30.0, 80.0, 130.0, 200.0, 320.0];

Thanks is advance.

  1. As clunk mentioned, you need to add the f suffix to numbers with decimal point, otherwise by default they are interpreted as double percision.

  2. Arrays in C# are not primitives and have to be explicitly initialized with the new keyword. Also, initial array data needs to be wrapped in curly braces:

    float levelmult;

    void Awake()
    {
        levelmult = new float[]{ 1.0f, 2.0f, 3.0f };
    }
    

It’s not too bad.

Try the first link, read the page. We’re not super smart or something, we just know how to use the tools at hand.