Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: Fat Pug Studio on March 21, 2016, 10:26:40 AM

Title: Make Sprite Flash When Hit [SOLVED]
Post by: Fat Pug Studio on March 21, 2016, 10:26:40 AM
Hello,

i would really like some help. I am making a side scrolling shooter, and i need to make enemy sprites flash when hit (player bullet box collider 2d coliding with enemy box collider 2d). I tried with set color, but that doesn't work.

Any ideas for the FSM?
Title: Re: Make Sprite Flash When Hit
Post by: Fat Pug Studio on March 22, 2016, 07:16:37 AM
Actually,

i made it, you can find the solution on the page i opened for sharing FSM's.

http://hutonggames.com/playmakerforum/index.php?topic=12301.msg57312#msg57312

Unfortunately, i can't figure out how to flash in WHITE color, it would be nice if someone would have an idea.
Title: Re: Make Sprite Flash When Hit
Post by: djaydino on March 22, 2016, 07:23:06 AM
Hi,
you could use "swap sprite" and swap with none
If you get a white box you can me a blanco sprite and use that.

There are a few different ways that you can do this.
a way you can use is use "action sequence" (right click in the state screen and select it)
then do "swap sprite / wait / swap  sprite / wait / swap  sprite / wait / swap  sprite / wait"

another way is by using the animator.
Title: Re: Make Sprite Flash When Hit
Post by: djaydino on March 22, 2016, 07:29:59 AM
Hi,
a way you could to this is to use a white sprite in front of the original sprite and change the alpha from the white sprite.
Title: Re: Make Sprite Flash When Hit
Post by: Fat Pug Studio on March 22, 2016, 07:51:59 AM
Well,

it's not quite the solution to make double sprites (normal and white) for every enemy object in the game. Anyway, i'll try that out too.

And about the second post, i don't quite understand you, how can i use white sprite in front of the original sprite?
Title: Re: Make Sprite Flash When Hit [PARTIALLY SOLVED]
Post by: Fat Pug Studio on August 26, 2016, 12:50:10 PM
Quote
And about the second post, i don't quite understand you, how can i use white sprite in front of the original sprite?

Now i know what you mean :)

It's been a few months, and i made a lot of progress, but there's the same wall i'm hitting again. I have an FSM with set property/color of the sprite render to red. The transition from state two to state three goes smoothly, but the color doesn't change. Object is Kinematic with discreete collision detection, it uses circle collider 2D. Other than that everything else is usual. It is on the same layer as the bullet that collides it.

Here's a screenshot of the FSM.

(https://s15.postimg.org/td6lh1czv/image.jpg)
Title: Re: Make Sprite Flash When Hit [PARTIALLY SOLVED]
Post by: djaydino on August 26, 2016, 08:36:14 PM
Hi,
I tried here, color seems to work but you can try materials/color

What version of unity and playmaker are you using?

Also you do not need to set every frame :)
Title: Re: Make Sprite Flash When Hit [PARTIALLY SOLVED]
Post by: Fat Pug Studio on August 27, 2016, 08:56:57 AM
Well guess what, i deleted the FSM and made a new one, now it works. Thanks!
Title: Re: Make Sprite Flash When Hit [SOLVED]
Post by: djaydino on August 28, 2016, 09:00:52 AM
Hi,
What version of unity and playmaker are you using?
Title: Re: Make Sprite Flash When Hit [SOLVED]
Post by: Fat Pug Studio on August 29, 2016, 03:15:59 AM
Hello djaydino,

i solved the problem, i think it was wrong because i imported the template that was no longer working, and made an FSM in it. When created in fresh FSM, it worked. Unity 5.3.5f1, Playmaker 1.8.1.f10.