playMaker

Author Topic: Make Sprite Flash When Hit [SOLVED]  (Read 3792 times)

krmko

  • Beta Group
  • Hero Member
  • *
  • Posts: 992
    • View Profile
    • Fat Pug Studio
Make Sprite Flash When Hit [SOLVED]
« on: March 21, 2016, 07: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?
« Last Edit: August 27, 2016, 05:57:38 AM by krmko »

krmko

  • Beta Group
  • Hero Member
  • *
  • Posts: 992
    • View Profile
    • Fat Pug Studio
Re: Make Sprite Flash When Hit
« Reply #1 on: March 22, 2016, 04: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.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 4585
    • View Profile
    • jinxtergames
Re: Make Sprite Flash When Hit
« Reply #2 on: March 22, 2016, 04: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.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 4585
    • View Profile
    • jinxtergames
Re: Make Sprite Flash When Hit
« Reply #3 on: March 22, 2016, 04: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.

krmko

  • Beta Group
  • Hero Member
  • *
  • Posts: 992
    • View Profile
    • Fat Pug Studio
Re: Make Sprite Flash When Hit
« Reply #4 on: March 22, 2016, 04: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?
« Last Edit: March 22, 2016, 05:02:08 AM by krmko »

krmko

  • Beta Group
  • Hero Member
  • *
  • Posts: 992
    • View Profile
    • Fat Pug Studio
Re: Make Sprite Flash When Hit [PARTIALLY SOLVED]
« Reply #5 on: August 26, 2016, 09:50:10 AM »
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.


djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 4585
    • View Profile
    • jinxtergames
Re: Make Sprite Flash When Hit [PARTIALLY SOLVED]
« Reply #6 on: August 26, 2016, 05: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 :)

krmko

  • Beta Group
  • Hero Member
  • *
  • Posts: 992
    • View Profile
    • Fat Pug Studio
Re: Make Sprite Flash When Hit [PARTIALLY SOLVED]
« Reply #7 on: August 27, 2016, 05:56:57 AM »
Well guess what, i deleted the FSM and made a new one, now it works. Thanks!

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 4585
    • View Profile
    • jinxtergames
Re: Make Sprite Flash When Hit [SOLVED]
« Reply #8 on: August 28, 2016, 06:00:52 AM »
Hi,
What version of unity and playmaker are you using?

krmko

  • Beta Group
  • Hero Member
  • *
  • Posts: 992
    • View Profile
    • Fat Pug Studio
Re: Make Sprite Flash When Hit [SOLVED]
« Reply #9 on: August 29, 2016, 12: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.