Particle System On Key Press

I’m trying to add a particle effect when my player walks in my game, but I don’t even know where to begin. Can anybody help me? It’s a 2D game in case it matters.

Go to : GameObject > Create Other > Particle System

Under “Particle System” on the particles in the Inspector, un-tick “Play On Awake”

In your player script, reference the ParticleSystem at the top of the class:

public ParticleSystem particles;

Drag the particles in your Hierarchy view into the particles variable slot on the player script.

Where you check for movement in your player script, do something like the following:

    if(Input.GetKeyDown(KeyCode.A)){
    	particles.Play();
    }
    
    if(Input.GetKeyUp(KeyCode.A)){
    	particles.Stop();
    }

Or if you are using GetAxis or GetAxisRaw:

	float axis = Input.GetAxis("Horizontal");

	if(axis < 0 || axis > 0 && !particles.isPlaying){
		particles.Play();
	}

    else if(particles.isPlaying){
		particles.Stop();
	}

That should be enough to get you on the right track.

Start from the beginning