using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class abrirPuerta : MonoBehaviour
{
public Text abrirPuertaText;
public Animator puerta;
private bool show;
public AudioClip button;
public AudioClip door;
private AudioSource audioSetup;
void Start()
{
abrirPuertaText.text = "";
show = false;
puerta.SetBool("on", false);
audioSetup = GetComponent<AudioSource>();
}
private void Update()
{
if (show)
{
abrirPuertaText.text = "Pulsa 'E' para abrir la puerta.";
}
else
{
abrirPuertaText.text = "";
}
if (Input.GetKeyDown(KeyCode.E) && show == true && puerta.GetBool("on") == false)
{
audioSetup.clip = button;
audioSetup.Play();
audioSetup.clip = door;
audioSetup.Play();
puerta.SetBool("on", true);
}
else
{
if (Input.GetKeyDown(KeyCode.E) && show == true && puerta.GetBool("on") == true)
{
audioSetup.clip = door;
audioSetup.Play();
puerta.SetBool("on", false);
}
}
}
private void OnTriggerEnter(Collider other)
{
if (other.tag == "Player")
{
show = true;
}
}
private void OnTriggerExit(Collider other)
{
if (other.tag == "Player")
{
show = false;
}
}
}
I dragged the animations, text, audio etc and still not working dunno why because it was working but now even with ctrl+z wont work anymore :S