Issue toggling Particle system on/off using bool.
So what i have seems to work the majority of the time, however occasionally when i hit E the particle system won't respond. Can someone have a look at what i have and figure out what i could be doing wrong?
This is my first time posting here so if i need to provide any additional details please let me know.
Thanks.
ParticleSystem campFire;
private bool isPlaying;
void Start()
{
campFire = GetComponent<ParticleSystem>();
isPlaying = false;
}
void Update()
{
if (Input.GetKey(KeyCode.E))
{
Debug.Log("E Was Pressed");
isPlaying = !isPlaying;
if (isPlaying)
{
campFire.Stop();
}
else
{
campFire.Play();
}
}
}
}
Answer by Jezzywezzy101 · Jan 20, 2017 at 11:15 AM
Solved the issue. Needed to change.
if (Input.GetKey(KeyCode.E))
to this.
if (Input.GetKeyDown(KeyCode.E))
Your answer
Follow this Question
Related Questions
Error CS0122: inaccessable due to protection level 1 Answer
How to make a thrown object land on a certain point e.g a thrown spear landing on its tip 0 Answers
Can't get my ball to move. 0 Answers
Dreamlo Leaderbord issue 0 Answers
How to add a editing option to variables in a script in Inspector? 0 Answers