On Overlap, Move actor away from overlapped actor

Hello! I am trying to figure out how to handle a custom overlap/collision scenario for a test project and keep running into dead ends or functionality that isn’t quite what I need.

To flesh out how I have things set up, I have a blueprint actor that spawns a model (a child static mesh) during runtime. Once these models are spawned I randomly place the spawning actor within a trigger volume.

One of my requirements is that no two models should overlap with each other. The first attempt I made was using a Get Random Point in Bounding Box and a Spawn Actor From Class node with the Collision Handling set to Attempt to Adjust but always spawn.

The Spawn Actor was created and place before the models were spawned which was causing the collision handling to not work as there was no collision mesh to work with. I then changed it so that the Spawn Actor is created before placement and made the model spawn before placing it at random within the volume but now I need to figure a way to handle the collision/overlap issue. At first I thought maybe a Sphere Collision but that didn’t work entirely the way I wanted it to. Instead I have implemented a Sphere Overlap which works in terms of detection as I need it to but now my problem is moving the spawned models if they are overlapping another model.

So far I have tried getting the location of the model being overlapped, multiplying it by -1, and then multiplying that by various values. I then break the vector output on the multiple vector/int and the location input on the Set Actor Location then use only the x and the y axes. For whatever reason, more often then not half of the models vanish from the level and the ones left do not move along the y-axis, only the x-axis. I also tried using the Get Unit Direction Vector node and doing the same thing with the output location as indicated above with the same results.

I have tried subtracting the locations and then adding to the output but that also had the same results as the other two. I get the overlapping actor’s location from the On Begin Overlap’s Other Actor node into a Get Actor Location node. I do the same on a “Self” node for the overlapped actor. Both actors are the Static Mesh which is a child component of the Spawner Actor.

Pretty much out of ideas at this point. There seems to be nearly no discussion of this type of scenario as far as I could find in four hours of Googling. What I have found has not been very helpful though did point me in the directions I attempted above.

Does anyone have any thoughts on how I can achieve this? Do I need to try and move the Spawner Actors instead of the static meshes?


Okay, so I solved by On Overlap issue. What was happening was that all of my objects were executing On Overlap Begin even if there was no overlap. Turns out they were overlapping themselves somehow. So I readded a sphere collision, turned off all collisions for the static meshes and now the On Begin Overlap is only firing for actually overlapping actors.

I also finally fixed by other problem. What I had to do was to take the overlapping actor’s location again and add it to the -1 multiplied result of the Get Unit Direction Vector. But there was a problem with that, some times it was moving my actors outside of the volume bounds that the Spawn Actor was placed so instead of using the Ger Unit Direction Vector node, I pulled in my nodes to get the volume’s bounds and then reapply the random location until it was placed in a location where it was no longer overlapping.

Everything works as expected now.

@Geowil When you’re working with ‘on overlap’ you need to cast to make sure the overlapping actor is the one you’re interested in… :slight_smile: ( otherwise you get everything )