3D Graphs in Unity

Hey folks,

I’m trying to follow CatlikeCoding’s tutorial on 3d graphs in unity. However seems that some features are deprecated. Disclaimer: I’m not terribly experienced with unity. Here’s the tutorial: http://catlikecoding.com/unity/tutorials/graphs/#a-questionmark

Rn i’m at this step of her tutorial:

void Start () {


        if (resolution < 10 || resolution > 100) {
            Debug.LogWarning ("Grapher resolution is out of bounds, resetting to minimum.", this);
            resolution = 10;
       
            float increment = 1f / (resolution - 1);
            for (int i = 0; i < resolution; i++) {
                float x = i * increment;
                points [i].position = new Vector3 (x, 0f, 0f);
                points [i].color = new Color (x, 0f, 0f);
                points [i].size = 0.1f;

            }
            points = new ParticleSystem.Particle[resolution];

        }
    }
    // Update is called once per frame
    void Update () {
        particleSystem.SetParticles(points, points.Length);


    }
}

My error is at the line inside of Update(). This is deprecated. So i replaced it by doing:

particles = GetComponent ();
(inside of Start)

Then in update i used: particles.SetParticles(points, points.Length);

However i’m getting an object reference not set to an instance of object error pointing to my Update function. Any help would be appreciated.

Have you assigned a particle system to the variable particleSystem Unity - Manual: Null Reference Exceptions

Try

particleSystem = GetComponent<ParticleSystem>();

So i’ve got
public ParticleSystem particleSystem;
at the top before start.

Then inside of start I have:

particleSystem = GetComponent<ParticleSystem>();

then in Update I have:

particleSystem.SetParticles(points, points.Length);

It’s still throwing the null reference error at the last line in Update.

Sounds like the script is not attached to a particle system game object. Instead of doing get component drag the particle system into the slot in the inspector.

Hmm, it is infact attached to the particle system. I created the component within the particle and it shows up in the inspector.