How make enemy flash when get hit? Paper2D

Hi… I want to have my enemy flashing when they’re hit… But I’m working on a paper 2D game, and when I create a material for the enemy, all the paper is painted… not only the enemy. Like in the print:

Someone could help me with it, or say something better to do instead of change the material?

Thanks a lot.

Gustavim,

I would think the best way to do this would be to create a flipbook for the animation of “getting hit”. Then whenever the player takes damage and your invoking your actions (ie: make temporarily invulnerable, knockback, take damage, etc) have it trigger the flipbook change. I’m working on a paper2d game myself and what I did was create an animation state engine that controls which flipbook is currently playing based upon a series of booleans (ie: IsCurrentlyRunning, IsCurrentlyJumping, etc) and update with the tick.

So when the player takes damage just have it set a variable to true (ie: RecentlyTookDamage) and set a delay = the animation length, then clear the Boolean. Then have a branch in your animation state engine say if RecentlyTookDamage = True then set flipbook to the taking damage animation.

Thank’s for your help Xeroize… I’ll try to do this… I think it will help me alot…
I hope help you one day :slight_smile:

Xeroize, I tried here to set a new color for the sprite, set a delay, and than back to the normal color, and it done what I need… I’m telling you it, because maybe it can help you too… See you!

Gustavim,

No problem, glad it worked out for you.

I’m currently working on the problem SpawnActor Spawning to Origin instead of Transform in Multiplayer - Multiplayer & Networking - Epic Developer Community Forums if you have any input to help there.