Hi I created two scenes where the player goes through scene 3-1 to scene 3-2 and from 3-2 to 3-1 in scene 3-2 there are enemies with an energy bar on them when the player defeats them and re-enter scene 3-2 the enemies reappear.
Hi, after reading the title of the topic and your post, it is not really clear what exactly your problem is.
If you don’t want the enemy to reappear in the scene, you need a global variable which you can check when entering the scene (for example: enemy_alive = true; after you defeated the enemy: enemy_alive = false → only if the variable is true you create the enemy in the scene).
Okay. Could you please describe a bit more what the actual problem is and what you expect to happen? So far I still don’t understand how the title and your posts are related. You know what your game is all about, but most forum members don’t.
For your last problem: each of your enemies needs to have an object variable that is tracking their health.
For example there are two scenes in the first scene there are 5 enemies the player eliminates one of these so four remain then it changes to the second scene and immediately after it changes again to the first scene where the enemy has been eliminated where there were 4 enemies left they have become again 5 the enemy who was eliminated has returned.
As for the variables, I used this scheme where the object variables of all those enemies are connected. I used an object variable on an enemy and then copied the same enemy 5 or 6 times in the scene.
If you want to have persistence over several scenes, you need to use global variables. Before going to the previous scene you can save the number of instances of your enemy in a global variable with the SceneInstancesCount()- expression. And then you use this variable for creating the correct number of enemy instances when you come back to the scene.
Btw you have a ‘repeat for each’-event together with a “trigger once while true”- condition. This is not working as you expect "Trigger once" with "Repeat for each instance": different result than expected. For creating the energy/health-bar you can put the loop in a subevent of an “At the beginning of the scene”-condition to make sure that the objects are only created once.
Can you kindly show me this example with a screenshot
Okay, for the number of enemies you could do something like this:
I don’t know how you create your enemies, but you can use the variable now for setting their number, e.g.
Ok thanks I’ll try this