here is the JS version:
var energyPoints:float = 100.0;
function MakeDamage (amount:float){
energyPoints -= amount;
}
function Update () {
if(energyPoints <= 0){
Destroy(transform.root);
}
}
and here is the C# version:
using UnityEngine;
using System.Collections;
public class damageControll : MonoBehaviour
{
public float energyPoints = 100.0f;
void MakeDamage(float amount)
{
energyPoints -= amount;
}
void Update()
{
if (energyPoints <= 0)
{
Destroy(transform.root);
}
}
}
I am using SendMessage("MakeDamage",damage) from other script. The JS version work just fine. C# version don't work. And by converting the JS script with http://m2h.nl/files/js_to_c.php I get the same code that I wrote by converting it by hand. I can't understand the error i make here. (and I a did a lot of research,and i can't solve this one. by my look such a simple looking problem).XD
Thank you in advance.