I am trying to create a system where when a Enemy mesh is spawned, a ai controller is going to be spawned and possess it. The reason I’m doing this is so that I can respawn the enemy and reuse the Controllers without getting unused memory.
The steps I think so far are:
In my game blueprint, I spawn the enemy blueprint.
In the characterbase class of my enemy, I spawn a ai controller if a new enemy mesh has been spawned
I possess it
When it’s destroyed, I unpossess,
destroy the mesh,
and that ai controller will keep checking whenever the new enemy mesh will be spawned.
My problem here is that I don’t know how I would check if a new enemy has been spawned.
Do I create a variable of object and set it with the return node of the spawn whenever I spawn anything new?
And what happens with that variable when I have more than one of the same type of enemy?
Any other suggestions?
Thanks in advance