- Home /
C# Emit Particle Upon Left Mouse Click
I want to get a shuriken system emitter to emit a single particle when you click the left mouse button. I'm unfamiliar with the shuriken particle system and I'm not sure what I need to do. All the variables I could think of using like maxParticle and emissionRate in Input.GetMouseButtonDown are controlled through time. So I'm not sure how to control the emitter this way.
using UnityEngine;
using System.Collections;
public class ParticleController : MonoBehaviour {
public GameObject particleEmitter;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (Input.GetMouseButtonDown (0)) {
//++particleEmitter.particleSystem.maxParticles;
//++particleEmitter.particleSystem.emissionRate;
}
}
}
Answer by Phles · Feb 18, 2014 at 06:39 AM
Hi,
You should be able to do this like so: particleEmitter.particleSystem.Emit(1);
Phill
Answer by Ashish Dwivedi · Feb 18, 2014 at 06:49 AM
First of all you need to adjust all the variables in the prefab accroding to what type of effect you want and then simply instantiate that prefab on "GetMouseButtonDown". If you think this is not your solution then can you explain a bit more? Most of the time in particle system no need accessing variables at runtime because what ever you want to acieve that can be done while making prefabs of your particle system.
Your answer
Follow this Question
Related Questions
C# Gameobject Rigidbody Mouse Collision 1 Answer
C# Changing Force over Lifetime Through Script 2 Answers
Get GameObject That Was Last Clicked? 2 Answers
C# Track Mouse Cursor Movement Speed 2 Answers