44 lines
1.0 KiB
C#
44 lines
1.0 KiB
C#
using System.Collections;
|
|
using UnityEngine;
|
|
using UnityEngine.VFX;
|
|
|
|
public class RobotMouthAnimator : MonoBehaviour
|
|
{
|
|
[SerializeField] private VisualEffect fireEffect;
|
|
|
|
[SerializeField] private Light fireLight;
|
|
|
|
private Animator anim;
|
|
|
|
// Start is called before the first frame update
|
|
private void Start()
|
|
{
|
|
anim = GetComponent<Animator>();
|
|
fireLight.gameObject.SetActive(false);
|
|
}
|
|
|
|
// Update is called once per frame
|
|
private void Update()
|
|
{
|
|
if (Input.GetKeyDown(KeyCode.Return))
|
|
{
|
|
anim.SetBool("FlapsOpen", !anim.GetBool("FlapsOpen"));
|
|
if (anim.GetBool("FlapsOpen"))
|
|
{
|
|
StartCoroutine(WaitToFire());
|
|
}
|
|
else
|
|
{
|
|
fireEffect.Stop();
|
|
fireLight.gameObject.SetActive(false);
|
|
}
|
|
}
|
|
}
|
|
|
|
private IEnumerator WaitToFire()
|
|
{
|
|
yield return new WaitForSeconds(1.5f);
|
|
fireEffect.Play();
|
|
fireLight.gameObject.SetActive(true);
|
|
}
|
|
} |