Spawn an actor on same position, but kill actor underneath it

Hi, I have a fixed position in my level where I want to spawn actors, selected from a widget. The actors have to spawn at the same position, but only one can spawn at the same time. So no overlap. When the actor is spawned you can grab it and place it elsewhere.

I made some BP with overlap actor, but don’t know how to set it up.

In text: Click on the widget item, is already an actor spawned (boolean?), so yes, destroy that actor (but not the others who are already placed somewhere else in the level) and place the new selected actor on the right position.

I can’t figure it out in BP. Can anybody help me out?
Thanks in advance!

Hi Mikeymore,

I haven’t tried it out yet but maybe the following could work for you.

You could set up a Trigger Box (This is invisible during Game Play), then use the GetOverlappingActors function to return an Array of all overlapping Actors. You then destroy any actors from that Array list before calling your Spawn Actors function.

Text: Click on the widget item, Get the Trigger box, GetOverlappingActors , Destroy Actors, spawn new actor.

Just be careful, if you have multiple Trigger Boxes you may need to do it in another way or use some kind of check to make sure you are using the correct Trigger Box.

Also, GetOverlappingActors has the “Class Filter” option that can be very helpful to prevent destroying other actors you weren’t expecting to. Alternatively, do a check before calling Destroy Actor that you have gotten an Actor you actually want to destroy and not something like a floor, light, wall, etc.

Hi, thanks a lot for the quick reply!!

Spawning is a sort of working, but the location isn’t good.

I got this BP so far:

I guess it has something to do with my Spawn transform. I set it to 0,0,0 and also to the right location where I want my blok-BP, but no luck.
It’s unclear to me if I have to set the location numbers of the BP or the static mesh in the blok-BP?

Maybe I have to set this spawn transform different?
I also tried a socket, but didn’t manage to get it working either.

Hi Mikeymore,

Have you had any luck yet?

You would want to set it on the Actor BP and not the static mesh. Changing the static mesh position will make this much more complicated when trying to move the Actor later on.

Could you share what is currently set in your spawn transform please?

Hi SylarAtomic, Thanks again for the reply!

The spawning is working now, I had wrong spawn location numbers, so it didn’t work that way.

I have placed 1 actor BP in the level, interfering with a trigger and when selecting the BP 1 till 3 the right actor spawns at the right location and the other is destroyed.

Only issue left: when I grab an actor and place it somewhere in the level, the spawing of new actors of that serie isn’t working.
So when there’s nothing at the original spawn location.

When I place back one of the actors in the original spawn location, it works again…

Something to fix about that?
Thanks in advance!

I have tried something with a branch with condition Is Overlapping actor, but it didn’t work the way I want.

Maybe that has something to do with the order in my nodes from Unreal?

Could you show me the nodes that you think are having a problem please?

This is how I tried it:

Not sure if this will fix it but you need to move the Spawn Actor after finishing the loop. Currently, after every time you call Destroy Actor you are calling SpawnActor. You need the SpawnActor to happen from the Complete Node.

Thanks a lot!!!

That did the trick. It’s working now!

I have learned a lot thanks to you…

1 Like

Fantastic! Glad you learned something new :grin: