Quantcast
Channel: Latest Questions on Unity Answers
Viewing all articles
Browse latest Browse all 171066

Cannot assign to 'Respawn' because it is a 'method group'?

$
0
0
Hello again, I have yet another problem with the health script I have been trying to write, First off here is my code: using UnityEngine; using System.Collections; public class Health : MonoBehaviour { public float maxHealth = 100.0f ; public float curHealth = 100.0f ; public GameObject Player; void Start(){ } void Update(){ if(curHealth < 0){ curHealth = 0; } if(curHealth > maxHealth){ curHealth = maxHealth ; } if(Respawn = true){ ApplyDamage(-100.0f); } } void OnGUI(){ GUI.Label(new Rect(100,100,100,100), curHealth + "/" + maxHealth); } void Respawn(bool boo){ Instantiate(Player, new Vector3 (23.21657f, 3.257863f, -0.6684538f), Quaternion.identity); Destroy(Player); } void ApplyDamage(float damage){ curHealth -= damage ; } void OnTriggerEnter(Collider other) { if(other.gameObject.CompareTag("Zombie")){ ApplyDamage(10); if(curHealth <= 0.0f){ //Instantiate(Player, new Vector3 (23.21657f, 3.257863f, -0.6684538f), Quaternion.identity); //Destroy(Player); Respawn(true); } } } } Ok so, I am currently able to respawn with this code but my health stays at 0, I tried using curHealth = 100; in the Respawn but it doesn't work, I also tried using ApplyDamage(-100.0f) in it but neither worked, so I went on to add an if statement (currently in the code) to set the health if Respawn = true but i get the error above. Can someone explain what the error means and possibly help me with a solution to setting my health after respawn?

Viewing all articles
Browse latest Browse all 171066


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>