x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

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.

alt text

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)

alt text

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.

alt text

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

Product Version: UE 4.18
Tags:
more ▼

asked Feb 06 '18 at 09:10 PM in Blueprint Scripting

avatar image

SoulRunner
5 1 4

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

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!

more ▼

answered Feb 06 '18 at 09:55 PM

avatar image

Jin_VE
4.4k 32 77 42

avatar image SoulRunner Feb 06 '18 at 10:12 PM

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.

avatar image Jin_VE Feb 06 '18 at 10:35 PM

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.

avatar image SoulRunner Feb 08 '18 at 01:35 PM

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. alt text

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

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

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

avatar image Jin_VE Feb 08 '18 at 06:45 PM

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);
 }
(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question