Hey guys,
I need a bit of help here, I’m doing a 2D game and I’m using the following functions:
private const int PLAYER_DAMAGE = 1;
private void OnCollisionEnter2D(Collision2D collision)
{
if (collision.gameObject.tag == "EnemyWizard")
collision.gameObject.GetComponent<EnemyHealth>().EnemyHurt(PLAYER_DAMAGE); // Take off health
}
private void OnCollisionStay2D(Collision2D collision)
{
if (collision.gameObject.tag == "EnemyWizard")
collision.gameObject.GetComponent<EnemyHealth>().EnemyHurt(PLAYER_DAMAGE); // Take off health
}
It’s used to make damages to an enemy when the object is in the area. The problem is that when I’m in development mode, the damages are alright, approx 50dmg/second but when I build the game and put the setting in Ultra, the damages go at like 5000dmg/sec which is not nice.
I think the problem comes from the OnCollisionStay2D function and I need to limit it, for instance in development mode it’s called every 0.02 sec and when in ultra it’s called every 0.0002 sec.
Does anyone can help me on this?
Thanks by advance,
Dyanek