I finally got my score working. I now need help in understanding how to get the score to increase when an enemy dies. Does anyone know why when I use “player has just fired” the score counter works, but when I select “enemy is dead” the score counter does not work?
I am using the 8 bit shooter template and when I chose Enemy1 is dead, the score does not change. As far as I can tell the Enemy1 is losing all its health and then being deleted, so I can’t figure why the score counter isn’t working.
Increase the score in the same event when the Enemy1 is deleted. If there’s a chance that multiple enemies can be hit simultaneously, then it will need extra sub events. But that can be dealt with later.
For now, just increase the score in the same event that the Enemy1 is deleted, and remove the event where you check if it’s dead.
Thank you MrMen. That solved my problem. It all works now. I just moved my score increase code to my scene event (instead of external event) and now all works. Thanks my friend! It still is confusing why my code didn’t work in the external event, since I did check if the enemy was dead there?
Because the Enemy1 had been deleted by that stage. The Enemy1 is dead check goes through all the Enemy1 objects in the scene , and selects only those marked as dead. Because the dead one had been removed, it wasn’t captured by the event conditions.
External events keep a set of events in a separate file. When you link to the external events, you’re effectively including those events at the point of the link. When the game runs, GDevelop treats it as if you’d copied and pasted the events at the link point.
And it’s not about priority - if you’d put the Enemy is dead event in the level scene events, it still would have made no difference. It’s the order things were done.
External events are great if you have repeated code over multiple scenes, so you only need to make a change in one spot. They can also help keep the code a tidier by having more compact appearance, making the easier to read and follow.
Wow, thank you for that explanation. I’ve been wondering why my external link was not working correctly. Now I know. I put the link at the bottom of my level events, at the end of my code. Ok that makes alot of sense now.