Hello!
I’m trying to create a power up that stops the player from taking damage for a limited amount of time. Think Mario Star, Halo Sheild, Whatever. Here’s what I think needs to happen:
First Set up a Invincibility Timer:
var InvinceTimer : float =10;
Then in the update function count it down (Eventually it should be wrapped up in a function, but I’m just trying to see if this works)
InvinceTimer -= 1 * Time.deltaTime;
Last, do an if statement to check if the countdown is 0. If it is, apply damage on an enemy hit:
public function ApplyDamage(d:int)
{
if (InvinceTimer <= 0)
{
playerFear +=d;
print("damaged by : "+d);
}
}
So What currently happens: If the timer is set to 0 from the start, the player takes damage. If the timer is set to anything other than 0, the player doesn’t take damage. For some reason however, the countdown in update does not seem to be actually decremented based on time. What am I doing wrong? If someone has an example of what I’m trying to do, it’d be much appreciated!