Can't instantiate Particle System... "The thing you want to instantiate is null"

Hi guys. I can’t get the Particle System to instantiate after the Enemy hits the Player… I get “The thing you want to instantiate is null” but I don’t get why.

using UnityEngine;
using System.Collections;

public class Hit : MonoBehaviour {
    Vector3 OriginalPosition;
    Vector3 LastPosition;
    // Use this for initialization
    void Start () {
        OriginalPosition = transform.position;
        LastPosition = transform.position;

    }
   
    // Update is called once per frame
    void OnCollisionEnter (Collision col) {
        if (col.gameObject.name == "Enemy") {
            gameObject.GetComponent<Renderer> ().enabled = false;
            gameObject.GetComponent<Collider> ().enabled = false;
            Instantiate(Resources.Load("DeathErupt") as ParticleSystem, LastPosition, Quaternion.identity );
        }
    }
}

You probably dont have a valid prefab called DeathErupt in a Resource folder. Make sure you do and that it has a particle component attached

I do have this prefab. I tried putting it in “Assets”, I tried putting it in a folder called “Resources”, or in a folder called “Prefabs”… didn’t help. What do you mean by “and that it has a particle component attached”? It’s a particle system I created and I saw that it works fine in scene view if I put it in the hierarchy.

If you have the prefab in a folder called Resources (Inside the Assets folder of your project, not in a subdirectory of it) and it is named DeathErupt and the prefab has a ParticleSystem component on its root, it should work.
I usually never instantiate GameObjects by referencing their components, perhaps you could try that aswell.

Turns out I just needed to make it “public” and drag it to the right location. It works now, thanks :slight_smile: