This repository has been archived on 2023-09-13. You can view files and clone it, but cannot push or open issues or pull requests.
station_obscurum_unity/Assets/Scripts/Enemies/Robot/RobotMouthAnimator.cs

44 lines
1.0 KiB
C#
Raw Normal View History

2023-05-31 17:12:43 +02:00
using System.Collections;
using UnityEngine;
using UnityEngine.VFX;
public class RobotMouthAnimator : MonoBehaviour
{
2023-06-01 17:03:48 +02:00
[SerializeField] private VisualEffect fireEffect;
[SerializeField] private Light fireLight;
2023-05-31 17:12:43 +02:00
private Animator anim;
2023-06-01 17:03:48 +02:00
2023-05-31 17:12:43 +02:00
// Start is called before the first frame update
2023-06-01 17:03:48 +02:00
private void Start()
2023-05-31 17:12:43 +02:00
{
anim = GetComponent<Animator>();
fireLight.gameObject.SetActive(false);
}
// Update is called once per frame
2023-06-01 17:03:48 +02:00
private void Update()
2023-05-31 17:12:43 +02:00
{
if (Input.GetKeyDown(KeyCode.Return))
{
anim.SetBool("FlapsOpen", !anim.GetBool("FlapsOpen"));
if (anim.GetBool("FlapsOpen"))
{
StartCoroutine(WaitToFire());
}
else
{
fireEffect.Stop();
fireLight.gameObject.SetActive(false);
}
}
}
2023-06-01 17:03:48 +02:00
2023-05-31 17:12:43 +02:00
private IEnumerator WaitToFire()
{
yield return new WaitForSeconds(1.5f);
fireEffect.Play();
fireLight.gameObject.SetActive(true);
}
2023-06-01 17:03:48 +02:00
}