弾幕ゲームで、Bossがplayerにパーティクルシステムの弾を当てると、関数 Hit が1増え、
5になると Gameoverのシーンに移るようにしているつもりなのですが、当たっているのに
移りません。
なぜでしょうか。Unityです。
エラーは出ていません。
まだ5日めの初心者なので、簡単なところをみのがしているかもしれません。
パーティクルシステム using UnityEngine; using System.Collections; public class ParticlController : MonoBehaviour { // Use this for initialization void Start () { } // Update is called once per frame void Update () { } void OnParticleCollision(GameObject obj){ Debug.Log ("Particle HIt"); obj.transform.gameObject.SendMessage("Damage"); } }
プレイヤーコントローラー using UnityEngine; using System.Collections; public class PlayerController : MonoBehaviour { float timer; float Hit; // Use this for initialization void Start () { Hit = 0; } // Update is called once per frame void Update () { timer += Time.deltaTime; if(Input.GetKey("left")){ if(transform.position.x > -20){ transform.position += new Vector3 (-0.1f, 0, 0); } } if(Input.GetKey("right")){ if(transform.position.x < 20){ transform.position += new Vector3 (0.1f, 0, 0); } } if(Input.GetKey("up")){ transform.position += new Vector3 (0,0 , 0.1f); } if(Input.GetKey("down")){ transform.position += new Vector3 (0, 0, -0.1f); } if (transform.position.z < 90) { transform.position += new Vector3 (0, 0, 0.02f); } if (Hit > 4) { Destroy(this.gameObject); Application.LoadLevel ("Gameover"); } if (Hit == 4) { //Destroy (Yuka.gameObject); } } void OnCollisionEnter (Collision col){ Debug.Log (col.gameObject.name); if (col.gameObject.tag == "enemy") { Destroy (this.gameObject); Application.LoadLevel ("Gameover"); } } public void Damage(){ Debug.Log ("PlayerHit"); //Destroy (this.gameObject); Hit = Hit + 1; } }