You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

40 lines
1016 B

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[RequireComponent(typeof(ParticleSystem))]
public class ToggleFireParticle : MonoBehaviour
{
public KeyCode toggleKey = KeyCode.Space;
private ParticleSystem fireParticle;
public ParticleSystem igniteParticle;
public ParticleSystem extinguishParticle;
public GameObject pointLight;
private void Start()
{
fireParticle = GetComponent<ParticleSystem>();
}
void Update()
{
if (Input.GetKeyDown(toggleKey))
{
if(fireParticle.isPlaying)
{
fireParticle.Stop();
pointLight.SetActive(false);
if (extinguishParticle != null)
extinguishParticle.Play();
} else
{
fireParticle.Play();
pointLight.SetActive(true);
if (igniteParticle != null)
igniteParticle.Play();
}
}
}
}