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

47 lines
1.1 KiB
C#
Raw Normal View History

2023-05-31 17:12:43 +02:00
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);
}
}