I’m making a little game where if you go into certain areas there is a chance of being attacked, a bit like in Final Fantasy. How do I make it so that when I’m in the area, that it’s a second, I randomly see if you’re being attacked? I have written this, but it runs constantly, so you would be attacked all the time. Any suggestions on how to set a timer?
private void OnTriggerStay(Collider other)
{
if (other.gameObject.tag == "Grass")
{
if (Random.Range(1, 101) <= 5)
{
print("Found an enemy");
}
}
}