Pressing a key starts a particle system help

Hello,

I am using a character controller to move around and I also have a particle system. What I am trying to figure out is how can I make it so I can start my particle system by pressing a key in the game mode. I dont have much experience with any programming.

If anyone could show me a script on how to do this I would greatly appreciate it.

Thanks

Using the documentation. I can get that you first need to make sure that your particle system is not playing to start.

Then you need to get a key input.

For this you will need a keycode

Lastly, when that input is pressed, jsut start your particle system

Hey. Using the information you have given me I have tried and used this script but it didnt work.

#pragma strict

function Start () {

var emissionTime : float = 3.0;
var emissionDelay : float = 3.0;
var lastTime = 0.0;

function Update()
{
if (Input.GetKeyDown (KeyCode.H))
{
GetComponent(Particlesystem).autodestruct = false;
particlesystem.particle = true;
lastTime = Time.time;
}
if (particlesystem.particle (Time.time - lastTime) > emissionTime)
{
particleEmitter.particle = false;
}

}

Im not sure if this is even close but would it be too much trouble if you could write out the script?

Thanks

Bump.

This is a mod, using the documentation as a guide. You should use the doc’s to help you learn. Do small things first. (this is actually a small thing, but make their stuff work for you first.)

#pragma strict

var emissionTime : float = 3.0;
var emissionDelay : float = 3.0;
var quitTime = 0.0;
var particlesystem:ParticleSystem;

function Start () {
	particlesystem = gameObject.GetComponent(ParticleSystem);

	//first need to make sure that your particle system is not playing to start.
	particlesystem.playOnAwake = false;
}



function Update(){
	// Then you need to get a key input.
	// For this you will need a keycode
	if (Input.GetKeyDown (KeyCode.H)){
		particlesystem.Play();
		quitTime = Time.time + emissionTime;
	}
	if (particlesystem.isPlaying  Time.time > quitTime){
		particlesystem.Stop();
	}
}

Oh, and when posting code, use “code” tags. :wink:

Hey thank you so much it worked!