Search Unity

Make an image flash

Discussion in '2D' started by krupps, Oct 11, 2019.

  1. krupps

    krupps

    Joined:
    Oct 17, 2017
    Posts:
    41
    I have a Prefab with images and an avatar for a cooldown ability.

    I have a circle image (knob), but I want to flash it for 1 second, bright like a flash from a camera to show it's ready.

    How would I make the know have an extra brightness like a camera flash?
     
  2. jeffreyschoch

    jeffreyschoch

    Joined:
    Jan 21, 2015
    Posts:
    2,602
    Simplest way would be to briefly show another sprite on top of it with the "flash" shape, like a shape with an alpha gradient or something.
     
  3. krupps

    krupps

    Joined:
    Oct 17, 2017
    Posts:
    41
    Is there any special material type or just a normal 255,255,255?
     
  4. jeffreyschoch

    jeffreyschoch

    Joined:
    Jan 21, 2015
    Posts:
    2,602
    Unless you want to use post-processing with a bloom effect or something, it would just be another normal sprite with the default sprite material.

    I've attached an example, a simple white gradient that is 100% alpha in the center, and 0% alpha at the edges. Could be used to as a flash effect potentially by turning it on and off or fading it in and out, but for the best effect you would want to make one that fits your art style.
     

    Attached Files:

    krupps likes this.
  5. MisterSkitz

    MisterSkitz

    Joined:
    Sep 2, 2015
    Posts:
    519
    You could make a duplicate of your image and turn it into a material Additive and add it into a particle system. Set the amount of max particles to 1 and set your duration to 1.00. Also set your particle lifetime to 1 and your start speed to what makes it look the best. You may need to change the particle shape to box or edge depending on how it looks as a cone.

    I'm pretty sure you may need to set gravity to 0, set particle size & size accordingly. One last thing that I can think of (without opening unity and looking at the particle components) is that you would want to set your emission rate to 0 and add a burst with 1 for particles.

    This should make the image appear flashing if you make sure Looping and PlayOnAwake are both checked.

    Edit: Think you can also do color over lifetime to make it change colors for an added flash effect as well. I would play around with the Noise component as well, but just don't use too much noise because it can cause performance issues; however, a little noise can make some pretty rad effects!
     
    vakabaka and krupps like this.
  6. krupps

    krupps

    Joined:
    Oct 17, 2017
    Posts:
    41
    Thank you so much for that. After I implemented a Cross Fade I was able to get a nice ambient flash.
     
  7. krupps

    krupps

    Joined:
    Oct 17, 2017
    Posts:
    41
    That sounds really cool
     
    mchodor and MisterSkitz like this.
  8. MisterSkitz

    MisterSkitz

    Joined:
    Sep 2, 2015
    Posts:
    519
    Try it, lemme know how it goes. I wouldn't even mind seeing a video of it :)