void Update() { if (!Game_Manager.UpdateAllowed || !myPlayer.isAlive()) { return; } RaycastHit[] Hits; Hits = Physics.RaycastAll(myPlayer.Mesh.position + Vector3.up, Vector3.down, 5); int HitAmount = 0; bool CPHit = false; foreach (RaycastHit Hit in Hits) { if (Hit.transform.tag == "CP" || Hit.transform.tag == "PF") { HitAmount++; if (LastHit == Hit.transform) { return; } LastHit = Hit.transform; //handles Invincibility if Alive and something is below if (Hit.transform.gameObject.tag == "CP") { //Debug.Log("CollisionRay hit CP", this); myPlayer.ChangeStatus(2); if (!Hit.transform.GetComponent <ParticleSystem>().isPlaying) { Hit.transform.GetComponent <ParticleSystem>().Play(); Hit.transform.GetChild(0).GetComponent <Light>().enabled = true; myPlayer.GetComponentInChildren <Light>().spotAngle += 5; } //Loading next Level if its the last Checkpoint if (Game_Manager.LevelManager.IsInGoal(myPlayer.Mesh.position)) { Debug.Log("Final Checkpoint!", this); myPlayer.ChangeStatus(0); Game_Manager.InvokePrepareNextLvl(3); } CPHit = true; } else if (Hit.transform.gameObject.tag == "PF" && !CPHit) { myPlayer.ChangeStatus(1); //Debug.Log("CollisionRay hit PF", this); } } } if (HitAmount == 0) //don't just use Hits.Length because it might contain the Playermodel itself as well { Debug.Log("Player killed: Outside map", this); Game_Manager.PlayerManager.KillPlayer(transform.GetComponent <Player>()); Game_Manager.PlayerManager.RespawnInvoke(3, myPlayer); } }