Spawn Actors Adjacent to Destroyed Actor. Detecting Other of the same Type.

Greetings everyone.

I am new to Unreal and still learning things. And i wanted to ask how i could go about creating something like this below? I Know it’s an awful drawing but i thought a Visual View might help as i am poor at explaining.

I want to create a System that when i Break a Rock, When Rock Destroyed, Create Rocks around it at adjacent areas that would be touching. If there are Rocks already in the way, It won’t spawn a rock there, A way to check that ‘Oh theres empty space! I’ll make a rock!’

I was Mostly Struggling with getting the Rocks to spawn from the Destroyed Actor? I went with a Method of a Custom event that was ‘Rock Destroyed’ Which when it was triggered, It would Spawn Rock (x) Away from Destroyed Actor. Except i seemed to either Always spawn a Rock at 0.0.0 In the World, Or Would cause an Infinite Loop? My Best attempt was this shown here but i could barely get 1 Rock to place how i wanted and I am slightly Dreading having to make this work + Figuring out how to Detect whether an object should be placed in a space or not? Any help would be appreciated.

Thank you.

1 Like

Box BP ( it just contains a cube )

In this example, I set

image

box trace

The ‘End play’ event runs when an actor is destroyed. You can destroy the cube any way you want. At the moment, I’m just doing a line trace from the player and using ‘destroy actor’.

1 Like

Greetings!

Thank you so much for the assistance, Following this i got quite close but i Ran into an issue where The Spawn point Vector plugged into the Spawn Transform Location on the Spawn Actor Rock BP Would Cause UE To Stop Responding if Compiled While the Branch ‘False’ Was Plugged into the Spawn Actor. I Spent a day trying to figure this out but have been unable to Figure out why it Isn’t doing so. Would you have any Ideas on how to Fix this?

Edit: I Thought about Digging through the Logs, And Found this.

image

I’ve tried Faffing with the Transform for a solution but Each time i seem to only Make UE Unresponsive.

Many Thanks!

1 Like

Can you show your code?

1 Like

Will only let me Post 1 Media at a time.

1 Like

This is 50 :slight_smile:, then plug this bit in

I think it should be ok.

1 Like

Hello! Thank you for the Reply once more!

I’ve plugged these in and Added the Numbers as shown but i’m still Having Unreal Engine Go Unresponsive as Soon as i Compile. I’ve tried leaving it for a while In case i was just Impatient but all that happens is UE Uses More of Memory Till it Closes itself. Though i close it before hand.

1 Like

Okay So After Faffing a bit My Solution was for whatever Reason to Pull the Spawn Transform Out And ‘Get Rock Spawn’ From there, Rather than Getting it form my Variables. I Don’t know why that Let me Compile, I Tried it again the other way around and it still Froze up. But it works! And is very awesome, I look forward to playing with it more and i appreciate all the kind Help!

1 Like

Ok, weird, but good :slight_smile:

1 Like

Hello Again! I Just wanted to Leave one thing and Ask another!

First, I Found out the Memory Leaks freezing Unreal were Due to when i Destroyed something with the Line Trace, I was Trying to spawn from it after, Making it very Unhappy on the Compile, Doing this-

Whilst leading from a Custom event to start this instead. Fixed it! Was all a Hiccup from my end on the Line Trace.

I Also wanted to ask, I Can create these Box’s all around the Cube and it works great! I’ve been faffing and used an Array to Create a multiple Types of Spawns as well! I’m working on a weight system for % Chance to spawn. But i wanted to know, How could i make the Box’s spawn above and below it? I’ve been stumped on trying to get this to work, And would like to ask for assistance once more!

Many Thanks.

1 Like

Something simple you could do, to make boxes above and below, is to just spawn another copy of the same blueprint above and below, after you have spawned the cubes.

1 Like