47 lines
1.1 KiB
C#
47 lines
1.1 KiB
C#
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using UnityEngine;
|
||
|
using UnityEngine.VFX;
|
||
|
|
||
|
public class RobotMouthAnimator : MonoBehaviour
|
||
|
{
|
||
|
private Animator anim;
|
||
|
[SerializeField]
|
||
|
private VisualEffect fireEffect;
|
||
|
[SerializeField]
|
||
|
private Light fireLight;
|
||
|
// Start is called before the first frame update
|
||
|
void Start()
|
||
|
{
|
||
|
anim = GetComponent<Animator>();
|
||
|
fireLight.gameObject.SetActive(false);
|
||
|
}
|
||
|
|
||
|
// Update is called once per frame
|
||
|
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);
|
||
|
|
||
|
}
|
||
|
}
|