How do I make the player invulnerable for a small time?

 

First, we declare all the variables.

 

//Place in Create event

varHit=false;

varCount=0;

 

Then place this in the alarm 0 event to stop the blinking

 

//Place in Alarm 0 event

varHit=false

varCount=0

visible=true

 

This is the essence of the blinking:

 

//Place in Step event

if varHit=true{varCount+=1}

if varCount=4 //try messing with this to speed up or slow down the blinking

{visible=false}

if varCount=8 //always make sure this is double the first

{visible=true; varCount=0}

if varHit=false{varCount=0; visible=true}

 

And of course, we need to know whether the character is hit.

 

//Place in Collision event with enemy

if varHit=false{varHit=true; alarm[0]=100}