void OnCollisionStay2D(Collision2D collision)
{
if (collision.gameObject.name == "FollowEnemy")
{
HitPoint -= Damage;
Debug.Log("-1");
}
}
This code makes my player take 10 damage a second. My players health is 10. What can I do about this? Do I just lower the damage value or is there a better way to make collisionStay run slower?
if (collision.gamobject ETC ETC..)
{
time += Time.deltaTime;
if( time >= "whatever delay you want as float")
{
DealDamage();
time = 0f;
}
}
void DealDamage()
{
Hitpoints -= Damage;
}
2 Likes
Olmi
December 20, 2019, 3:31pm
3
You have to make a simple timer. Keep record of the time and apply damage after certain timer has passed, reset time and then repeat.
EDIT: well, looks like someone just pressed post button at the same time, with example code too.
2 Likes
Olmi:
You have to make a simple timer. Keep record of the time and apply damage after certain timer has passed, reset time and then repeat.
EDIT: well, looks like someone just pressed post button at the same time, with example code too.
I am noob, I dont get to help ppl often, so when I get a chance, I jump on it haha. to reduce the guilt of leeching help from this forum
3 Likes
Thank you so much! That makes Much more sense
1 Like