|
here is part of my script...it works...except by the time it kicks in it has already collided twice so instead of subtracting 10 hp it subtracts 20...this wouldn't be a big deal except I plan to switch to a hearts system later with much lower numbers if you want to use this code you will need the following -hp variable -knockback variable -isstunned variable (movement controls must be in an"if(isstuned >= 0)" statment and variable must be set to 1)
I hope my notes are informative to those wanting to use this ^_^...(does need a minor fix though so you might want to either wait on a fix or attempt it yourself lol)
(comments are locked)
|
|
Have a bool isDealingDamage = false. Change your if to: if(collision.gameObject.tag == "Bandit" && !isDealingDamage) On the first line of the if(){}block set isDealingDamage = true; On the last line of the if(){}block set isDealingDamage = false; Since both if blocks inside your if block have a WaitForSeconds(1) in them, there will be a 'buffer' of one second before damage can be dealt again.
(comments are locked)
|
|
You can create a dead time during which further collisions are ignored: Adjust the deadTime variable to avoid multiple damage for the same hit.
(comments are locked)
|
|
I really like both of your guys solutions...I ended up going with joshua's solution so I checked is as "right answer"
(comments are locked)
|

This is for a sidescroller / sidescrolling game by the way