Coding a Particle System to play when a GameObject hits ground.

I’m trying write a script so that when my GameObject, preferably a character hits the ground, it plays the particle of dust kicking up when you land. Right now just to make sure it at least works with a character, I’m using the Tag “Player”

I’m using the OnTriggerEnter function as a start, but the play function of the particle system gives me the error “An instance of type ‘UnityEngine.ParticleSystem’ is required to access non static member ‘Play’.”

function OnTriggerEnter(col:Collider)
{
	if(gameObject.tag == "Player")
	{
		ParticleSystem.Play;
	}
}

The idea is to call this in the update function.

well, instead of using particle.play();…you could use

 Instantiate(particle, transform.position, transform.rotation);

Hey, The problem you seem to be having here is that you aren’t referencing the particle you wish to use.

For example:

var particle : ParticleSystem;

function OnTriggerEnter(col:Collider)
{
    if(gameObject.tag == "Player")
    {
       particle.Play;
    }
}

Then you would drag the particle that you have created and want to play into the variable “particle” on the inspector.

Also you would need to set the particle to not play on awake so it doesn’t play when you don’t want it to.

Hope this helps :slight_smile: