- Home /
C# damage script help
I have borrowed this script in C#, which I attatch to my enemies. However, it keeps saying that there is a parsing error on the last line.
using UnityEngine;
using System.Collections;
public class EnemyHealth : MonoBehaviour {
public int maxHealth = 100;
public int curHealth = 100;
//initialization
void Start () { }
// Update
void Update () {
if (curHealth <1){
Destroy(gameObject);
}
}
void OnCollisionEnter(Collision col) {
if (col.gameObject.tag == "Bullet"){
curHealth -= 20;
Destroy(col.other);
}
}
You already said in the comments of the answer you took this code from. You waited about 5 $$anonymous$$utes for them to reply (they get notified by email most likely), and then posted a question on your own. Not cool.
$$anonymous$$y apologies to anyone who was offended, but I was just trying to get a quick answer. I am not in any way attempting to pass off this code as my own. I apologize to you if you somehow felt that the way that my comment was worded indicated otherwise. But, statistically speaking, posting requests for help on multiple channels will decrease the time required to wait for a response. I guess that I am just impatient. I am sorry. Would that I could delete this thread, because people are offended, but I can't.
Answer by csshelton70 · Jul 20, 2013 at 09:21 PM
Maybe two things: 1) I don't see the closing brace for the class. The one on line 20 is for the function. 2) Should col.other be col.gameObject?
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
OnDestroy() : Some objects were not cleaned up when closing the scene 1 Answer
Error NullReferenceException: Object reference not set to an instance of an object 1 Answer
'Visibility' job failed with error code: 2 0 Answers
Parsing Error at End of Script? 0 Answers