Hi, I have a problem, because in my game enemies are generated randomly (below I send how it works) and I would like to add something like EnemyVision, but I have no idea how to do it, so that the game generates e.g. 15 enemies and so that each of them has an object called EnemyVision (in short, so that EnemyVision always generates as many times as there are enemies)
You not only want to create something for each object but most likely attach it to each object?
Like i did this to attach HP bars
They get created for each object
And deleted with them
Using object linking
The idea is that if, for example, 15 rats are generated, then the same amount of EnemyVision will be generated as the number of rats, and EnemyVision will be connected to each rat separately (When I used your actions, the fps in games dropped to 5)
Press middle mouse button until you see Attack Mode in top left
Then you hit RMB to to create slimes
And LMB to attack
Each of them will get a bar as soon as their HP is not 100%
And there is no lag to it at all
And you can even download project file to check it out
And it uses same events from screenshot i provided in previous message
I followed your advice and I still don’t know how to do it because when I use the connected game I see something like this
I would like every generated enemy to have the Enemy Vision object, but only one enemy does
You’re deleting the spawn object, and then creating something at it’s position. But it’s deleted, so GDevelop doesn’t know where to place it.
Every time a rat is created, create an EnemyVision object for the rat and position it at the rat’s position (not the deleted spawn object).
I’d recommend you use the Sticker extension and stick the EnemyVision to the rat (here’s an older post on how to do this). As the rat moves and rotates, so does the EnemyVision that’s attached to it. No need to find the EnemyVision linked to a rat and reposition it.
Seriously, thank you, I didn’t even notice that I was deleting the spawn object
I followed your instructions and everything works now every enemy has EnemyVision, only when I set that after colliding with EnemyVision a rat runs towards the player all the rats start running. Do you know how to solve this so that only the one I have a collision with runs?
In the first event of you screen shot, add an “EnemyVision is stuck to Rat
” condition. Otherwise the move action is applied to all rats, as you’ve experienced.
Also, stick the EnemyVision to the enemy as soon as the enemy and EnemyVision are created, so the each EnemyVision is stuck to the correct enemy:
And finally, keep that “
Delete SpawnObject
” after each “Stick EnemyVision to ...
” action. It’ll prevent a SpawnObject being selected multiple times.
Could you please help me make it so that after killing e.g. a rat only its EnemyVision is removed?
In the event with the conditions to select the Rat, add the condition “EnemyVision is stuck to Rat
”, and delete the EnemyVision when the Rat is deleted.
Ideally you’d put all the enemy objects into an Object Group, and reference that instead of each object type.
Okay, thanks for your help
I have a problem, I don’t know how to remove Enemy Vision, can you help me? (I send events to my enemy)
You delete it, in the same event where you delete the enemy (the one with the blue dash outline). You got the list when you selected all the EnemyVision objects that belong dead Enemies.
In the actions, first unstick the EnemyVision and then do the deletion of Enemy and EnemyVision.