Instantiating a prefab at players location

Hi, I am trying to instantiate a one shot particle at the players location upon level up.

I have found the following code in the unity reference

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour {
    public Transform playerPrefab;
    void OnConnectedToServer() {
        Network.Instantiate(playerPrefab, transform.position, transform.rotation, 0);
    }
}

I know this is a network based one, but it shows me how to use the instantiate function

So I have the following code in my script:

public class ScriptPlayerOneManager : MonoBehaviour
        public Transform ParticleOneshotLevelUp;
    
    
    
    
public void playerOneLevelUp()			    	
            {
                
                Instantiate(ParticleOneshotLevelUp, transform.position, transform.rotation);
            }

When I run this I am getting a script error that says the variable of particleOneShotLevelUp has not been defined.

Please can someone point out my error?

You should create a prefab in the editor and than drag it onto the blank ParticleOneshotLevelUp variable on your script in the inspector if you haven’t already done so.
It should work after that.

Oh for goodness sake, I forgot that bit!

My excuse, Ive been coding for hours and I cant see the wood for the trees at the mo!

Thank you for pointing this out :slight_smile: