You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
789 B

  1. using UnityEngine;
  2. using System.Collections;
  3. public class respawners : MonoBehaviour {
  4. private bool player1;
  5. private bool player2;
  6. public GameObject respawnPoint;
  7. public GameObject deathTrigger;
  8. private checkpoint deathScript;
  9. // Use this for initialization
  10. void Start () {
  11. deathScript = deathTrigger.GetComponent<checkpoint> ();
  12. }
  13. // Update is called once per frame
  14. void Update () {
  15. }
  16. void OnTriggerStay(Collider other) {
  17. if (other.name == "Player1")
  18. player1 = true;
  19. if (other.name == "Player2")
  20. player2 = true;
  21. if (player1 && player2) {
  22. deathTrigger.SetActive(true);
  23. deathScript.respawnPoint = respawnPoint;
  24. gameObject.SetActive(false);
  25. if (this.transform.tag == "end") {
  26. Application.LoadLevel("CreditScene");
  27. }
  28. }
  29. }
  30. }