Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

respawn menu wont work

Discussion in 'Editor & General Support' started by gauty40, Sep 5, 2014.

  1. gauty40

    gauty40

    Joined:
    Feb 22, 2014
    Posts:
    15
    ive tried to set up and respawn menu within my player damage script and i cannot see why it will not work

    Code (csharp):
    1.  
    2. @scriptExecuteInEditMode()
    3.  
    4. varmaxHitPoints : int;
    5. varhitPoints : int;
    6. varpainSound : AudioClip;
    7. vardie : AudioClip;
    8. vardeadReplacement : Transform;
    9. varmySkin : GUISkin;
    10. varexplShake : GameObject;
    11. privatevarradar : GameObject;
    12. vardamageTexture : Texture;
    13. privatevartime : float = 0.0;
    14. privatevaralpha : float;
    15. privatevarcallFunction : boolean = false;
    16.  
    17. staticvarPlayerIsDead = false;
    18.  
    19. functionStart(){
    20. //hitPoints = maxHitPoints;
    21. alpha = 0;
    22. }
    23.  
    24. functionUpdate(){
    25. if (time > 0){
    26. time -= Time.deltaTime;
    27.  }
    28. alpha = time;
    29. }
    30.  
    31. functionPlayerDamage (damage : int) {
    32. if (hitPoints < 0.0)
    33. return;
    34.  
    35. //Applydamage
    36. hitPoints -= damage;
    37. audio.PlayOneShot(painSound, 1.0 / audio.volume);
    38. time = 2.0;
    39.  
    40.  
    41. //Arewedead?
    42. if (hitPoints <= 0.0){
    43. hitPoints=0.0;
    44. Die();
    45. PlayerIsDead = true;
    46. Debug.Log ("PlayerDied");
    47.  }
    48. }
    49.  
    50. //PickingupMedicKit
    51. functionMedic (medic : int){
    52.  
    53. hitPoints += medic;
    54.  
    55. if(hitPoints > maxHitPoints)
    56. hitPoints = maxHitPoints;
    57. }
    58.  
    59. functionDie () {
    60. if(callFunction)
    61. return;
    62. callFunction = true;
    63.  
    64. if (die && deadReplacement)
    65. AudioSource.PlayClipAtPoint(die, transform.position);
    66.  
    67. //Disableallscriptbehaviours (Essentiallydeactivatingplayercontrol)
    68. varcoms : Component[] = GetComponentsInChildren(MonoBehaviour);
    69. for (varbincoms) {
    70. varp : MonoBehaviour = basMonoBehaviour;
    71. if (p)
    72. p.enabled = false;
    73.  }
    74. //Disableallrenderers
    75. vargos = GetComponentsInChildren(Renderer);
    76. for( vargo : Rendereringos){
    77. go.enabled = false;
    78.  
    79.  }
    80. if(radar != null){
    81. radar = gameObject.FindWithTag("Radar");
    82. radar.gameObject.SetActive(false);
    83.  }
    84. Instantiate(deadReplacement, transform.position, transform.rotation);
    85. //yieldWaitForSeconds(4.5);
    86. //LevelLoadFade.FadeAndLoadLevel(Application.loadedLevel, Color.black, 2.0);
    87. }
    88.  
    89.  
    90. functionOnGUI () {
    91. GUI.skin = mySkin;
    92. varstyle1 = mySkin.customStyles[0];
    93. GUI.Label (Rect(40, Screen.height - 50,60,60),"Health: ");
    94. GUI.Label (Rect(100, Screen.height - 50,60,60),"" +hitPoints, style1);
    95. if (PlayerIsDead == true)
    96.  {
    97. if (GUI.Button(Rect(Screen.width*0.5-50, 200-20, 100, 40), "Respawn"))
    98.  {
    99. RespawnPlayer();
    100.  }
    101. if (GUI.Button(Rect(Screen.width*0.5-50, 240, 100, 40), "ExittoMenu"))
    102.  {
    103. Debug.Log ("ReturnToMenu");
    104.  }
    105. GUI.color = Color(1.0, 1.0, 1.0, alpha); //Color (r,g,b,a)
    106. GUI.DrawTexture(newRect(0,0,Screen.width, Screen.height), damageTexture);
    107. }
    108. }
    109. functionRespawnPlayer ()
    110. {
    111. Debug.Log ("RespawnPlayer");
    112. }
    113.  
    114. //functionDead ()
    115. //{
    116. //PlayerIsDead = true;
    117. //Debug.Log ("PlayerDied");
    118. //}
    119. //
    120.  
    121. functionExploasion(){
    122. explShake.animation.Play("exploasion");
    123. }
     
  2. frankrs

    frankrs

    Joined:
    Aug 29, 2009
    Posts:
    300
    why are you not putting spaces between words? like function (space) PlayerDamage or var (space) hitPoints ?
     
  3. gauty40

    gauty40

    Joined:
    Feb 22, 2014
    Posts:
    15
    i have, i dont know why its not showing up on the forum o.0
     
  4. orb

    orb

    Joined:
    Nov 24, 2010
    Posts:
    3,033
    I think you have to click the insert button now, rather than typong code tags manually, or it'll end up weird.

    As far as I can tell RespawnPlayer() doesn't actually do anything :)