Random Spawning and destroying.

I have targets in my world and i am spawning actor from class to those targets randomly. Inside the blueprint im spawning there is a click event that destroys the actor when clicked. And that all works fine. What im trying to do is when the actor is destroyed it will reset the randomizing system to spawn a new actor this system is in the level bp. Ive tried interfaces,event dispatchers none of them seem to be working. Does anyone how i can get this working?

Destroy function in actor

Random system

Where are you firing the event dispatchers?

i called the dispatcher in the actor blueprint before the destroy. And then the event inside the level blueprint. And the event was connected to the top pin of the multigate but its not in this screenshot.

That is a very bad setup you have there . I’m at work right now but I’ll post my random spawn system later .

Oh really? I wasnt sure how to start at first so i did some searching online and this is what i found. I would love to see what you did though. :stuck_out_tongue:

Sorry didn’t mean that how it sounded just meant for this type of thing you really need to be using arrays , loops and functions etc but it’s a good attempt. Can you post full screenshots of what you’re trying to do and like I said I’ll post up later thanks

Sorry the way i typed that kind of sounded rude, i didn’t mean it like that. those two screenshots are all i have and its all working just cannot get it to spawn a new one right away when one is destroyed.

Sorry I meant the bits the gate are connected too just so I can see everything thanks

Each pin the gate is conntected to is the same as the first pin. just for each target 23 in total.

The problem im having this the dispatchers working is you need to have the bp selected in the level to get it to appear in the level blueprint. (unless im missing something about dispatchers) and the actor is not in the level until it is spawned by the spawnactor from class. So how do i get reference to the actor that is not yet spawned?

Thanks can see what you are trying to do now sorry didn’t get a chance to log on to my computer yesterday . Will post up tonight

Ok, Thanks :smiley:

Ok, for some reason i always do things the hard. I took your advice and changed the setup to an array setup. But im still having issues trying to get reference for the dispatcher. This is the bit im stuck on still. Ill post a screenshot of my new setup.

Yeah much better and cleaner. Good job. Why are you using event tick I thought you only wanted to spawn a new bubble when the old one was destroyed?

yeah that was just to test it. i still cannot get the event to work when destroyed.

Ok so now just put this into a event or function call it spawnBubble or something. Place this event somewhere where you can call it for example in my case as my actor I’m destroying is a character I put mine inside the player controller if , or you can use player state game instance etc

Then all you do is in the input and on touch screenshot you posted above cast to wherever you have this spawnBubble event /function and call it THEN destroy the actor . So basically it will call the function spawn a new actor and destroy the old one . Sorry can’t post pictures .

Try and give it a go and let me know how you get on

I have that setup in the level blueprint right now. I am not able to select the actors to be in the array when i moved it to the player controller.

Instead of using an array of target actors , make the array an array of transforms that match the target actors position eg in the array you call it targetPos1 then set the X, y, ,z values to be the same as the target actor. It will take a bit of time to fill out at first as you have 23 but once it’s done it’s a much more flexible and editable system if you wanna add a new bubble spawn point you simpley add another transform to the array etc

Unfortunately the level blueprint is not a very good place to work with things as you cannot cast to it or access it from other blueprints.

This will work, another option though would be to use ‘get all actors of class’ node at the beginning of the level / game, in your controller / whatever blueprint you want these. Filter by the TargetActor class and that gives you an array of all the target actors in the map. If you dont want every target actor, or that doesn’t work, just make a new blank actor blueprint that you can use as a spawn location, and use get all actors to get an array of those to use for your spawning. That way you can continue to add as many spawn points as you like without having to manually enter in the location each time.

That worked and i didnt have to go through and add each instance of the actor :stuck_out_tongue: Thanks.

This is what you mean right?