Hello guys, its my first post here, hope you can help me…
I have a grenade object, that destroys itself in a certain time, and I have THIS FUNCTION CALLED IN OnDestroy() :
function AreaDamageEnemies(location : Vector3, radius : float , damage : float ) {
var objectsInRange : Collider[] = Physics.OverlapSphere(location, radius);
for (var hit : Collider in objectsInRange) {
if (!hit) {
continue;
}
var proximity : float = (location - hit.transform.position).magnitude;
var effect : float = 1 - (proximity / radius);
if (hit.tag == "Movible") {
hit.rigidbody.AddExplosionForce(50, this.transform.position, 10, 3.0);
}
if(hit.tag == "Blanco") {
var VidaNegra : ManejadordeBlancos = hit.GetComponent(ManejadordeBlancos);
var IA : InteligenciaArtificialNegra1 = hit.GetComponent(InteligenciaArtificialNegra1);
var NuevoVector : Vector3 = hit.transform.position - this.transform.position;
VidaNegra.DecrementaSalud(damage * effect);
IA.ExplosionGranada(NuevoVector);
}
if(hit.tag == "Vidrio") {
hit.GetComponent("VidaVidrios").VidaVidrio = 0;
}
if(hit.tag == "Player") {
var Vida : playerStatus = hit.GetComponent(playerStatus);
var varx = ((damage * effect) - 20);
if(varx > 0)
Vida.aplicarDamage(varx);
}
}
}
You dont have to fully understand what I do to every single tag, I talk spanish and program in spanish, so you wont understand most names, I just wants those “if´s” to be executed if its not a wall in the way…
I tried all the ways, I searched “Grenade damage” to page 5 of the forums but nothing will work, It must be me who is doing it wrong, can anybody help me?