Question by
Wasques · Feb 16, 2016 at 12:11 PM ·
unity 5ontriggerenteroncollisionenterontriggerexitoncollisionexit
How can I make a collider that gives me stat up to stop giving me it?
Hi, i'm begginer in unity2D and I want to make a collider that, when you hit it, it gives you "strength", I have already made it but when I hit this collider, the strenght increase never stops (just by hitting it one time). How can I make the collider to give just +1 strenght? Thanks. (Sorry about my english, hope you undestand it :P )
This is part of the script assigned to the collider.
void OnTriggerEnter2D(Collider2D col)
{
tocat = true;
atac1.enabled = false;
}
void OnTriggerExit2D(Collider2D col)
{
tocat = false;
Debug.Log("hola");
}
}
And here is the status increase script.
public class Texto : MonoBehaviour {
public GameObject colision;
public Atacc atacke;
public Text text;
public int atac;
// Use this for initialization
void Start () {
atacke = colision.GetComponent<Atacc>();
text = GetComponent<Text>();
}
// Update is called once per frame
void Update () {
text.text = " " + atac;
if (atacke.tocat == true) ++atac;
}
}
Comment