How do I blink a sprite when the player gets hit?

0 favourites
  • 7 posts
From the Asset Store
Players follower. use it for anything which follows the player
  • How do I make the player sprite blink/flash when it gets hit by a bullet?

    for instance:

    if (the player gets hit by a bullet){

    the player flashes with a solid white color}

    thanks!

  • there is a build in behavior called flash.

    Give it to your sprite and just add this

    Bullet on collision with sprite--------. sprite flash

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • there is a build in behavior called flash.

    Give it to your sprite and just add this

    Bullet on collision with sprite--------. sprite flash

    Ive already tried the flash behavior but it just turns the sprite invisible.

    Is there a way to make the sprite glow instead?

    thanks!

  • It makes your player invisible because it runs every tick and the flash behavior resets all the time. add a trigger once in your command to stop this from happening.

    you must understand how conditions work in programing.if something is true it will run 60times a second unless you tell it to do it only once when the condition triggers for the first time.

  • If you don't mind relying on WebGL effects, you could have the following:

    If [Bullet] overlaps [Player]
    ~~~then~~~
    Destroy [Bullet]
    Set [Player] effect [Brightness] [200]
    Wait [0.05] seconds
    Set [Player] effect [Brightness] [100]
    Wait [0.05] seconds
    Set [Player] effect [Brightness] [200]
    Wait [0.05] seconds
    Set [Player] effect [Brightness] [100][/code:6b2cmud1]
    
    That code makes the player flash twice. Make sure you give [Player] the tint effect first!
  • thats great! I felt really comfortable using the effect solution...

    thank you both for helping!

  • Or another alternative way is to create 5 animation sprites. Load it as an animation

    If bullet hits Player --> Destrory bullet

    --> Set Animation ("Animation name")

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)