Search Unity

Please Help Quickly!!!

Discussion in 'Scripting' started by freaka61, Apr 23, 2011.

  1. freaka61

    freaka61

    Joined:
    Jan 15, 2011
    Posts:
    27
    friends, i'm using 3rd Person Shooter (http://unity3d.com/support/resources/example-projects/3rdpersonshooter) and i wan't this: "if "player" death then game restart but if "orb" death then game resuming"
    how i do this? :confused: :(

    that's my "DeathManager.cs"
    Code (csharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class DeathManager : MonoBehaviour {
    5.    
    6.     public HealthController[] entities;
    7.     public ProgressBar[] progressBars;
    8.    
    9.     // Update is called once per frame
    10.     void Update () {
    11.         for (int i=0; i<entities.Length; i++) {
    12.             HealthController hc = entities[i];
    13.             if (hc == null)
    14.                 continue;
    15.            
    16.             if (hc.gameObject.active  hc.health <= 0) {
    17.                 entities[i] = null;
    18.                 hc.gameObject.SendMessage("Die");
    19.                 if (hc.tag == "Player")
    20.                     StartCoroutine(PrepareRestart(false));
    21.                 else {
    22.                     StartCoroutine(PrepareRestart(true));
    23.                 }
    24.             }
    25.         }
    26.     }
    27.    
    28.     IEnumerator PrepareRestart (bool won) {
    29.         if (won) {
    30.             yield return new WaitForSeconds (11);
    31.             Screen.lockCursor = false;
    32.         }
    33.         else {
    34.             yield return new WaitForSeconds (5);
    35.         }
    36.         Application.LoadLevel(0);
    37.     }
    38. }
    39.  
     
  2. Jessy

    Jessy

    Joined:
    Jun 7, 2007
    Posts:
    7,325
    That is not a good thread title. You could at least explain why we need to help so quickly.