Adjust spawn on x or y

currently i have a number of set spawn points around a level and am spawning all enemies from these spawns. i have it set to ajdust the spawn if it collides but this is expectantly causing adjustment on the z axis as well. i would like to restrict this so it can only adjust on the x and y as the game is from the top down shooter. Any ideas on how i can achieve this? Still quite new to UE4 overall i would say.
I have been using the normal Spawn Actor from Class node for this and spawning them on a target point.

Here is an image of the adjustment somewhat working in this corner however the yellow boxes in the top left have still spawned inside each other despite collision. (Yellow box in bottom right is out of map)

229778-a4230e984b06868da97c228b2dcfcddc.png

Here the boxes have spawned on the z axis and this both cannot hit the player and the player cannot hit it as it is too high up, spawning above the first box.

229780-c047386e2c5041ecb08ce8f89326885f.png

Lastly here is a screen of a number of enemies spawning just under the map due to adjustment on the z axis again.

I would try this but i want the spawning to be more dynamic when it adjusts. I would set standard spawns and it would spawn around them maybe. I mainly want this as it is a waved based mode with both mobile and stationary targets.

There may be a way to do it using your spawn method as it is. But you could always do it yourself.

Before you spawn an actor, use Sphere Overlap Actors to probe the spawn location. If you get overlaps then adjust the spawn location yourself so you can ignore the Z component. There is also Box Overlap Actors if you want to get a nice tight fit for box-shaped actors. And there is Capsule Overlap Actors to get a tighter fit for capsule-shaped actors (like humanoid characters).

Once you get a good location you can spawn them as “Always Spawn, Ignore Collisions” and it will spawn exactly where you tell it to (i.e. on your desired plane).

And you may want to test an area that is a bit larger than the spawned actor. That is, if things will be moving around during spawns (which they usually are). The larger area will account for the movement so you can be sure that by the time the actor is fully spawned, nothing has moved into its actual spawn area.

Hope that helps if you can’t find a built-in way. Good luck!

You sound like you don’t understand. Either the engine will handle it for you or you have to do it yourself. The method I provide is how you do it yourself. There’s really no possible variation: you probe the spot and spawn when it is clear. Perhaps you will try it if you can’t find an alternative. Time will tell.

I figured it out. It may be a variation of what you said. I haven’t given the game a direct spawn after the first but i have taken the spawn from the first and added random floats to give a random location based around the spawn point i wanted. This seems to be working exactly as i wanted. Using event tick during testing to always spawn actors i have made a few functions to keep the spawning running smoothly.

RandSpawn Function: Takes a spawn point (Hardcoded here) and randomises based off that.

SpawnActorFunction: Checks for collisions and either spawns or randomises, then spawns based on collision check

I have also set a 2 second timer using CanSpawn to slow down spawn rate.

End Result: (Random spawn on x and y axis)

229964-b6b067590cd0d10eb8fc5657412149ca.png

Randomness is by definition no guarantee that you won’t get overlap. I had another thought. Why don’t you just add this to BeginPlay of the actor:

FVector currentLocation = GetActorLocation();
if(currentLocation.Z != zPlane)
{
  currentLocation.Z = zPlane;
  SetActorLocation(currentLocation);
}