[Solved] Healthbar not working

I’m trying to have a health bar for each of the enemies but only one is created and i don’t know why this is. Any help would be greatly appreciated, thanks in advance!

this is the “how do I…?” section of the forum, not the “debug my code”. if you look in the debugger you could see all the instances was created in the first event. and then the second event put them all in one place.
move all action from the second event to the first event, and it will work.

This section is for any gamedev help with GDevelop, it’s the “how do I do that” section and it’s also the “that’s not working, help me fix it” section. If you’re not interested in debug challenges @Gyuszko , feel free to focus on the “how do I” types of topics. :slight_smile:

1 Like

In the second “for each…” you’re looping trough all the created instances of the enemy health bars and tell the events to move them to a position relative to the enemy… but the events don’t know to wich instance of the enemy, so it chooses always the same (the first one, I think). All the enemy health bars are there stacked and positioned relatively to the same enemy.

What you need to do is to use the Link Objects action in the first “for each…” loop, after creating the health bar, to properly link each instance of the enemy object to an instance of the enemy health bar object. Then, in the second “for each…” loop you need to use the take into account linked objects actions before modifying the enemy health bar (position, width, etc) to make the events understand wich enemy health bar corresponds to wich enemy.

The same actions will help you to do other things. For example deleting the correct enemy health bar when deleting an enemy after it’s killed.

Also, you need to put the first “for each…” loop under a condition that only triggers once. For example, at the start of the scene (if there’s when all the enemies shows up). If you don’t do that the events will be constantly creating new instances of the health bars and asigning them to the enemies every second (in fact, I’m sure this is currently happening even if you don’t see them, because they are stacked and behavioring the same way).

The second “for each…” loop is fine without conditions. It must run always without restrictions.

1 Like

yes, this is exactly what I want, but I can’t see which question is “real” how do I, because ewerybody put ewerything here as how do I.
how do I is how do I, bugfix is bugfix. if the question is how do I fix my bugs, the answer is easy. first, learn the BASICS of how GDevelop works, than may be learn advanced things, and practise, before you start developing CoD 12 or Fortnite 6…
I hate this kind of questions, because in 90 % of cases the problem is lack of knowledge! people come here and they don’t want to learn. just say something like " Hi I’m new to GDevelop…" and think they aren’t need to learn! I don’t understand these peoples!

(this post is not especially aganist MKayBye!)

People are here to learn and to gain knowledge. There is no official training course for GDevelop as far as I know so this How Do I forum is a place to gain knowledge, in conjunction with the Wiki and user-made tutorial videos online. These are all useful resources and when combined they can help people to make progress. If there was a full exhaustive training course for the software I could perhaps understand your frustration but I think you are missing the point of the forum, it’s for anyone, at any level, to ask more experienced users for tips and advice.

yes, but we has Wiki. and user made tutorials, and example files, ect.

the topic’s name is how do I. if it will be the place to gain knowledge, “knowledge center” would be its name.

there is nothing wrong with that, if you gain knowledge from posts by others, I did too (and do it currently). what I say is learn at least the basics before posting. because in the 90 % of cases clearly visible it isn’t any problem, bug or issue only the lack of the basics knowledge!

“How Do I” and “Knowledge Center” is just semantics. They are essentially referring to the same objective of learning new information.

I understand what you’re saying about the basics, from your perspective it could be frustrating seeing simplistic questions being asked, but when someone new starts using the software, if they have no previous programming knowledge, what might seem like “the basics” to you, could seem like “advanced level programming” to a new user. There isn’t a clear definition in a new user’s mind what a basic question is because they are inexperienced. A solution which seems obvious and simple to you might seem very difficult to a new user.

the only reason for this: I learn the basics, (not all yet, i’m just a beginner too) and they aren’t!

So if someone is asking a basic question then just give them a direct link to where their question is answered. Using a sweeping statement like “learn the basics” isn’t really helpful to anyone.

why should I (or someone else) search in the Wiki instead of him?! Wiki is almost the only one knowledge base of us. alwasy start the searching there!
or I should teach how to use Google?!

They might not know exactly what to search for, or if they have the right solution to their question. To a beginner, that Wiki can seem quite overwhelming. Asking other programmers with experience can help to pinpoint solutions much quicker than depending exclusively on a static Wiki.

In my point of view, all you have right!
I also understand the thinkings of each.
I also think that if new users knew where to find the responses to their questions, they would directly look at informations in the good place (by example: the Wiki)
I shall add it is more convenient and friendly to ask people than looking at and reading the Wiki: we are humans and we need communication too.

I think sometimes is better to use the How do I? because a lot of members read these posts, and can help on specific issues. But also think a lot of user just ask his/her questions here.
And they have not read neither the wiki nor the gdevelop documentation, and when publishing their queries they are not descriptive enough, this makes posts eternal, or confusing.

1 Like

Yes, all this is true!
But we see the same attitude of members on all forum, particulary the new users who have as excuse the fact not to know neither the forum nor the GDevelop product…
To come back to the original discussion, if one member creates a post in the category “How do i that…” which is in fact a section with all sort of requests of users who generally, don’t take the time to read the others categories and posts, this is not very important and too prejudiciable for others.

I know how you feel @Gyuszko, but there are many possible reasons why someone hasn’t found the answer in the wiki or the available tutorials, and it’s none of our business.
We’re here to offer help, education, support and kind words.
If you’re not able to offer a kind answer for any reason, simply ignore and move to another topic, don’t answer. :slight_smile:
Easy questions allow beginners to help super-beginners, which is nice. :+1:

And on my moderator side, if I see someone being too lazy and asking too many easy questions, I will send a private message about it.

Now, everyone, let’s stop the offtopic please, and thank @erdo for taking the time to explain the cause of the problem and its solution. :clap:

2 Likes

@MKayBye can you confirm if you solved the issue?

1 Like

Yh I solved the issue, thanks for the help! :slight_smile: