using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using UnityEngine.SceneManagement; public class Hitted : MonoBehaviour { public AudioClip HitSound; private AudioSource audioSource; public Sprite[] ShowSprites; public GameObject ShowObject; Image m_ImageShow; int Lives=3; // Use this for initialization void Start () { audioSource = GetComponent(); m_ImageShow = ShowObject.GetComponent(); m_ImageShow.sprite = ShowSprites[Lives]; } // Update is called once per frame void Update () { } void OnTriggerEnter(Collider other) { if (other.tag == "enemy") { Debug.Log(other.tag.ToString()); Lives--; if (Lives <= 0) { Lives = 0; SceneManager.LoadScene(0); } m_ImageShow.sprite = ShowSprites[Lives]; other.gameObject.transform.position = new Vector3(0, 5.0f, -1); } } }