**Hi! my trouble it’s this…
When the Object n°1 enter in the Object n°2 (this another with the script with OnTriggerEnter2D function)
it should discount points of life, but the life of the enemy (object n°2) decrease life’s continously
all object have: Rigidbody 2d’s , Colliders 2d’s and all active “Trigger” why i need.
object N°1 ----> Rayo (Rain / weapon)
object n°2 .-----> Enemigo (Enemy/Prefab)**
Enemy C# code
using UnityEngine;
using System.Collections;
public class EnemigoSalud : MonoBehaviour {
public int vidaMaxima;
public int vidaActual;
public int fuerza;
bool tocado;
void Start () {
vidaMaxima=100;
vidaActual=vidaMaxima;
}
void Update () {
if (tocado){
vidaActual-=fuerza;
}
}
void OnTriggerEnter2D (Collider2D Other){
if (Other.CompareTag("Rayo")){
tocado=true;
}
}
void OnTriggerExit2D (Collider2D Other){
tocado=false;
}
}
Rain C# code
using UnityEngine;
using System.Collections;
public class Rayo : MonoBehaviour {
void Update (){
if (Input.GetMouseButtonUp(0))
Destroy(gameObject);
}
}