- Home /
My attack script is broken, please help.
Right, a bit of explaining for this first. Ok, so I was working on my game, and I had a short hiatus due to lots of school assignments. When I came back, I kept having the issue of "Internal Complier Error". I tried as hard as I could, but no matter what, I couldn't find the problem. Until, that is, I found an empty file. I deleted it. And then the complier error was fixed.
Problem is, I thought the source of the problem was my zombie attack script, as that was the last thing I had been scripting when the error appeared. So that meant after weeks of frustration, I tore the script apart, testing and testing, trying to find out what the issue was.
And when the issue was fixed and script returned, it won't work anymore. I have re-written it, searched online, copied other scripts to try them, but nothing will work. As in, I can fix the compiler errors, that's easy, but the problem is that the zombies will rush the player, then just kind of float on his head, doing no damage and just clipping into him.
So, last resort, I am posting any related scripts here in a desperate hope for help. It just seems to not work, and I have no idea why. Please help.
Zombie Attack Script:
var damage = 10;
function OnCollisionEnter(col : Collision) {
if(col.gameObject.tag=="Player"){
col.gameObject.BroadCastMessage("HealthDamage", damage, SendMessageOptions.DontRequireReceiver);
}
}
Note, that is not my original script. I have tried tons of different scripts, and tried combining some, but nothing works.
Player Health Script:
var PlayerMaxHealth : int = 100;
var PlayerCurrentHealth : int;
var ZombieDamage : int = 25;
function Start () {
PlayerCurrentHealth = PlayerMaxHealth;
}
function OnGUI () {
GUI.Label (Rect (40, 40, 150, 40),"Health: " + PlayerCurrentHealth);
}
function HealthDamage (damage : int) {
PlayerCurrentHealth -= damage;
}
function Update () {
if ( PlayerCurrentHealth <= 0){ // if life reached 0 load level ShowScore
Application.LoadLevel("ShowScore");
}
}
I also have some scraps of code that I saved, I believe this is the closest I have left to my original code, but this isn't a functioning script, but merely a notepad of code.
enter code herefunction OnCollisionEnter (col : Collision) {
col.gameObject.BroadCastMessage("ApplyDamage", ZombieAttack, SendMessageOptions.DontRequireReceiver);
var ZombieAttack : int = 25;
function Start () {
}
function OnTriggerEnter (collision : Collider)
{
if (collision.CompareTag ("Player")) // Need to call CompareTag!
{
var options = SendMessageOptions.DontRequireReceiver;
collision.SendMessage("ApplyDamage");
}
}
I am happy to post anything else that could help, but I am really out of ideas. Please help.
Answer by Fornoreason1000 · May 01, 2013 at 11:18 AM
"Internal Complier Error" is bad news... Internal compiler errors usually have nothing to do with your scripting ... (though they can be made by overlapping Generics in C#.) errors like these should be Bug reported. sometimes restarting Unity fixes them. there's isn't really much you can do.
also this isn't the first time this question has been answered. the devs tend to get anal over duplicated questions.
try googling "Unity Internal Compiler Error".
Your answer
Follow this Question
Related Questions
Ai Zombie Melee Attack script. 5 Answers
Zombie attack script help 1 Answer
How can I make my Axe in unity do damage to my Zombies 6 Answers
Attack Script 1 Answer
Script Attack zombie 1 Answer