void OnCollisionEnter(Collision other) { // All the collisions there shall happen when Lars picks up an item or gets hit by an enemy if (other.gameObject.name == "HeartHP(Clone)") { HeroHP += 10; } if (other.gameObject.name == "appleseed(Clone)") { Points++; } if (other.gameObject.name == "GreenAPPLE(Clone)") { HeroHP -= AppleGREEN.GetATK(); } if (other.gameObject.name == "YellowAPPLE(Clone)") { HeroHP -= AppleYELLOW.GetATK(); } if (other.gameObject.name == "RedAPPLE(Clone)") { HeroHP -= AppleRed.GetATK(); } if (other.gameObject.name == "treeRoot(Clone)") { HeroHP -= tree.GetATK(); } if (other.gameObject.name == "TreeBOSS(Clone)") { HeroHP = 0; } }
void OnCollisionEnter(Collision other) { if (other.gameObject.name == "BallOfFire(Clone)") { GetHit(BallOfFire.GetBallDmg()); // When the Ball of Fire hits an apple it will get hit with the ball's damage print(AppleGREEN.GetHP() + " " + AppleRed.GetHP() + " " + AppleYELLOW.GetHP() + " " + Lars.GetHeroHP()); } if (other.gameObject.name == "Lars") { for (float i = 0f; i < 5f; i += 0.1f) //making the Apple jump y=5 up sort of slowly when touched by lars, giving him time to get away { transform.position += new Vector3(0, i, 0) * Time.deltaTime; } } }