// Update is called once per frame void Update() { if (IsSick) { Animator anim = GetComponent <Animator> (); if (anim.GetCurrentAnimatorStateInfo(0).IsName("PigIdle")) { IsSick = false; Game2Global.SetSick(false); } } }
public void Sick() { Animator anim = GetComponent <Animator> (); anim.Play("PigSick", -1, 0.0f); GetComponent <AudioSource>().PlayOneShot(SickSound); Game2Global.SetSick(true); GameObject hpObj = GameObject.Instantiate(HPNortify) as GameObject; hpObj.SetActive(true); hpObj.transform.position = this.transform.position; hpObj.GetComponent <HPNotification>().DecreaseLife(1); IsSick = true; }