Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » invincible period
- butterbufff
-
1 post
invincible period
how do i make invincible period (the moment you get hit by an enemy and you get a brief moment where you can't lose anymore health in which you can use to get away from the enemy)
- bubble103
-
500+ posts
invincible period
There are a few different ways you could do this depending on what you have in place already - what does your current script for when the player is hit by an enemy look like?
- Uniquename1
-
100+ posts
invincible period
In the script that keeps track of the health you could just have a wait however long block or make it flash over time. The time it is waiting or flashing it won't register the hit again. Just make sure nothing you need to have happen at that time (i.e. movement) is in the same script chain because the whole chain will be paused waiting for the flashing or just waiting for the time you set to finish before it starts running again and checking for collisions.
- footsocktoe
-
1000+ posts
invincible period
how do i make invincible period (the moment you get hit by an enemy and you get a brief moment where you can't lose anymore health in which you can use to get away from the enemy)
IF/THEN blocks handle situations where you want something to happen or not happen if something else happens or does not happen.
Like this…
repeat until <(GAME OVER?)=[true]>
if <(Hit by enemy?) = [true]> then
if <(timer) > [2]> then
change [HEALTH v] by (-1)
reset timer
end
end
end
Last edited by footsocktoe (April 25, 2017 18:40:53)
- Discussion Forums
- » Help with Scripts
-
» invincible period