private void OnCollisionEnter(Collision collision) { if (collision.gameObject.tag == "Player") { if (OrcaManager2.orcamodori == false) { if (transform.position.y < 11) { Debug.Log("10"); //HP回復 Hpcontroller.CurrentHP(-10); //スコア追加 scoreController.AddScore(-10); //餌生成関数を呼び出し feedGenerator.GetComponent <FeedGenerator>().Revival(); } else { Debug.Log("20"); //HP回復 Hpcontroller.CurrentHP(-10); //スコア追加 scoreController.AddScore(-10); //餌生成関数を呼び出し feedGenerator.GetComponent <FeedGenerator>().Revival(); } } Destroy(gameObject); } }
void Update() { Movement(); //当たり判定 Vector2 p1 = transform.position; Vector2 p2 = this.player.transform.position; Vector2 dir = p1 - p2; float d = dir.magnitude; float r1 = 0.5f; float r2 = 1.0f; if (d < r1 + r2) { if (transform.position.y < 4) { scoreController.AddScore(10); Hpcontroller.CurrentHP(10); } else { scoreController.AddScore(20); Hpcontroller.CurrentHP(20); } //feedGenerator.Count(1); Destroy(gameObject); } }
private void OnCollisionEnter(Collision collision) { if (collision.gameObject.tag == "Player") { if (transform.position.y < 11) { Debug.Log("10"); //HP回復 Hpcontroller.CurrentHP(5); //スコア追加 scoreController.AddScore(10); //餌生成関数を呼び出し randoms.Generate(); } else { Debug.Log("20"); //HP回復 Hpcontroller.CurrentHP(10); //スコア追加 scoreController.AddScore(20); //餌生成関数を呼び出し randoms.Generate(); } Destroy(gameObject); } }