void OnTriggerEnter2D(Collider2D other) { if (other.tag == "Player") { damagedSFX.Play(); other.GetComponent <PlayerHealth>().arms -= 1; // Remove an arm from the Player myCamera.GetComponent <CameraShake>().TriggerShake(); tm.phrase = truth; tm.Exclaim(); GameObject temp = Instantiate(trueFormObject, gameObject.GetComponent <Transform>()); temp.GetComponent <SpriteRenderer>().sprite = trueForm; temp.transform.localScale = new Vector3(0.1f, 0.1f, 0.1f); temp.transform.parent = null; // The following code ensures that BackBatch only runs once. if (isColliding) { return; } isColliding = true; hm.BackBatch(); } }
void OnTriggerEnter2D(Collider2D other) { if (other.tag == "Player") { gotFoodSFX.Play(); healSFX.Play(); tm.phrase = truth; tm.Exclaim(); GameObject temp = Instantiate(trueFormObject, gameObject.GetComponent <Transform>()); temp.GetComponent <SpriteRenderer>().sprite = trueForm; temp.transform.localScale = new Vector3(0.1f, 0.1f, 0.1f); temp.transform.parent = null; other.GetComponent <PlayerHealth>().arms += 1; // Add an arm from the Player Destroy(gameObject); } }