Hi, so just for understanding, the upper events are not yours, that’s just an example you found?
The second event should just work, if the hp is lower or equal to 0.
Your spawn event should also work as intended. What are you doing with the TargetRoundButton after creation? If you don’t move it anywhere the buttons will just spawn at the same spot and it may look as there is just one of them without disappearing. Maybe that’s obvious but it is hard to say what is going on without seeing your other events.
Yes, the first image is an example while the second one is my code
I did couple of things after creating the TargetRoundButton. I let it move towards an object (with pathfinding behavior) and when the TargetRoundButton goes near enough the tower placeholder with animation#1 (indicating a tower is placed on the tower placeholder), the tower placeholder will create bullet, starting from tower placeholder towards the TargetRoundButton, subtracting 2 hp from TargetRoundButton. Here’s the code related to everything mentioned above:
After copying every single line of code and objects (with same name) into a new scene, I realise that the code does not spawn any TargetRoundButton. The one TargetROundButton I mentioned earlier was not spawned by the code but is originally in the scene (I placed it on the scene).
When you click ‘start preview and debugger’ you can see the preview and behind the debugger window. In the inspectors-window is a button ‘refresh’. After clicking it will show all the objects in your scene and also the instances of your spawned TargetRoundButton - if they are being spawned.
I hope Rasterisko is okay when I answer this question. In your events you delete TargetRoundButton when its hp-variable is 0. If you, by chance, spawn the instances of TargetRoundButton with 0 hp they will be immediately deleted, so you have to make sure that your object has an hp value over 0 as an object variable.
I tried it, there is only 1 TargetRoundButton (again, it is the one I placed it in the scene)
I am not sure if I did this correctly, I change the hp variable of TargetRoundButton at the beginning of the scene, after that spawn 1 TargetRountButton every 2 seconds. I think this may be related to my problem because actually there is another problem which is about the second-last line of code:
The money keeps adding 50 about every 2 seconds, which is the “spawn” timer value.
Okay, you can set the object variable of your TargetRoundButton in the scene editor. You click on the three dots next to your object and choose ‘Edit object variables’. You have to make sure that the name of your variable is exatly the one you use in your events (case sensitive).
If you set the object variable at the beginning of the scene it applies this value only to the object that is in the scene and not to those that are created later.