How do I make enemies with health bars?

0 favourites
From the Asset Store
Health, Weapon & Rage Bars for your Games. Easy to use & Customize.
  • Thank you Jayjay I understood it! It helped me a lot!

    Okey so I did what you told me:

    When Health is less then < 1 then animation play...

    1.) When the bullet colliding with 2 of them the healthbar doesn't seem to know what to do? IMAGE - 1

    2.)But the death animation keep repeating over again. The repeat animation is set to 1 so once why does it do that then? do you have any idea? IMAGE - 2

    I don't know how to thank you, you helped me so much on this...

  • Frap1K Glad to see it's starting to take shape, nice looking game so far!

    But remember, any objects in a container can't be destroyed unless you are also okay with everything else in the container being destroyed too. Try changing it so that the objects you don't want anymore are "Set Visible" set to "Invisible" and disable collisions (don't know that one from memory though).

    Also, the healthbars being offset comes down to image hotspots, as the math for positioning the healtbar assumes it has a hotspot in its center.

    As for issue #2, try adding a variable to the zombie like "alive" and have it start as 1, then in event 41 add the condition to check if alive = 1. Then you can set alive to 0 in the actions for it so it never triggers again after the first trigger

    And anytime! I'm really glad to help

  • Hey Jayjay Thank you! Everything works now! I set it all invisible so the zombie is only visible for the player but when the zombies are standing in the same line and position, what happens is when I shoot the zombie they die together so it doesn't really matter if there are 100 of them(zombies) you will still kill them with 2 bullets in the head as it takes away 50 health from 100... .

    So I have come up with Idea creating:

    Solid sprite that will separate them both from colliding together - Which is a pink block

    But...The zombies spazzing out (going crazy all over the place) when I add it.

    Which is the best way of doing it?

    • Putting the zombieCollider into the >> Zombie Container? that's what I tried doing ant I failed somewhere (thats where the zombie was spazzing out all over the map)
    • On start of layout Pin it to each zombie?
    • or any other ways to do it?

    Thank you for you help I appreciate it!

  • Awesome progress I would try first just destroying the bullets when they collide first before trying those other methods, but otherwise I think adding it to the container, then on start of layout (or when a zombie is created) you position the pink box to the center of the zombie and then pin it. Hope that helps too!

    Nice graphics by the way!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hey Jayjay Ty for replying! Yes I did the bullet collide it with zombie but it wont work as the zombies are standing at exact same pixel. So it's gonna kill them both or if there is 10 of them.

    I'm having trouble with creating the thing you told me . I'm probably doing something wrong again ...

    What Happens:

    Maybe it's because the pink box is too low? how do I align it to the center ?

    Thank you again!

  • Ah, be sure to move the "On Collision" events out from underneath the For Each, that should make it trigger only once per bullet (then you can destroy the bullet), whereas if it's under the For Each it will run for every enemy before being destroyed.

    In the pink box case, change the Y value for "Set position to" from Zombie.Y to (Zombie.Y - Zombie.Height / 2)

    That should center it on the zombie

  • Hey Jayjay, I tried but wasn't sure what to move, didn't work !

    But do I move that marked with green? or with dark-blue?

    Is it okey if my pink block behavior is set to solid?

  • Move all four of those outside of the For Each (so they are on the same level). In practice the easiest way is move all for at once (hold control to select multiple) above the For Each. And it should be fine if the box is solid yes

  • Okey Jayjay I have created Collision_zombie(PINK BOX) - On start of layout - Set position & Pin

    I moved the 4 collision bullets away, but even without the pink box ti still kills 2 of them and it's still does that random flying thing

    Im good with images but not good with coding this ...

    Sorry for bothering you on this one soo much

  • Ah, make sure to destroy the bullet before the Wait 2 seconds action, otherwise it probably will trigger other events, and no problem! I am glad to help

  • I would remove the is overlapping event in the for each event, for it's unnescassary, because the zombiebox and zombieheadbox are already in the container with the zombie so the actions will only affect the ones concerned.

    These overlapping events event could create issues when two zombies are overlapping..

  • Okey LittleStain Ill try it! Thank you!

  • It didn't work LittleStain, The Hitboxes just stay in one place they dont follow the zombie. But Is there a way to make the PINK Box Sprite collide?

    As soon as I removed the Solid from the Zombie behavior it stopped flying across the map with the high speed...

  • Jayjay It woker! But I cant set their Behaviour to Solid... But how will they Collide then?? o.O

    Thank you, for your attention!

  • Jayjay It woker! But I cant set their Behaviour to Solid... But how will they Collide then?? o.O

    Thank you, for your attention!

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