Announcement

Collapse
No announcement yet.

Spawning Enemies

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Spawning Enemies

    So I'm making a roguelike game and the levels are generated by placing level segments next to each other in a random order. I want enemies to spawn in the segments, but what I do right now is a little bit inefficient. Currently, my system is based off the endless runner tutorial put out by unreal, I spawn the enemies the way they spawn the obstacles in this video https://www.youtube.com/watch?v=qzFd-PfM5kc but I'd like to be able to make a lot of segments and customize the enemy placements and spawning quickly. Right now to make a new segment I have to copy all the blueprint code into each new segment, place all the arrows, add the code for each enemy, and then tweaking that takes a long time too. My first idea was just to drag and drop the enemy blueprints into the segment blueprint, but when the segments are placed during gameplay, the enemies freeze where they were placed and don't seem to activate. Is there some way I can activate them on startup so I can just drag and drop them in to the segment blueprint? Or is there a more efficient/tweakable way to spawn enemies in general? Here are pics hopefully explaining better: Click image for larger version

Name:	Capture.PNG
Views:	1
Size:	584.6 KB
ID:	1156013 Click image for larger version

Name:	Capture2.PNG
Views:	1
Size:	572.1 KB
ID:	1156014

    #2
    Just a quick thought, id probably add a trigger over the previous segment, so that as the player moves into a new segment, it would then spawn a list of enemies in the following segment before it comes into view.

    All you need to do is add an array of all the enemies you want to spawn for each segment.

    Also, adding them as components is not the way to handle this at all. Adding them as components make them become part of the segment physically. You need to spawn them dynamically using the Spawn Actor from Class node.
    Im an Moderator on UnrealSlackers Discord! Which is a Community driven group of likeminded people here to discuss UE4! Join UnrealSlackers on Discord!

    Comment


      #3
      DevilsD, I'm currently spawning them the way you described, I mentioned that in my post, but I want an easier way to create the segments. Again detailed by my post, I know that adding them as components doesn't work by itself, I was wondering if there is another way to do it, or a way to detach the enemies from the segment during gameplay. What do you mean by adding a trigger and spawning a list of enemies? I'm not sure what you mean by that

      Comment


        #4
        On each of your Segments, add a collision mesh that will act like a trigger when the Player walks into it. Imagine 2 segments next to each other, the first segments trigger tells the game to spawn your enemies in the NEXT segment. As the player moves forward, each segment triggers the spawning of enemies in the following segment. Using this method, you wouldnt need to physically add the enemies within the editor to each segment, you just define a list of the enemies you want to spawn in each particular segment when the segments trigger is activated.
        Im an Moderator on UnrealSlackers Discord! Which is a Community driven group of likeminded people here to discuss UE4! Join UnrealSlackers on Discord!

        Comment


          #5
          Heres a quick example i threw together of what im trying to explain.



          You will notice, as the player moves into a new segment, the following segment spawns a few spheres, which in the example case are defined as my "Enemies". The number of enemies as well as their type are all predefined on the segment itself. The example is pulled far out to show what the spawning looks like, but ideally, each segment would be screen size so that the actual spawning of the enemies is not visible to the player and happens off screen.

          If you would like a run down of how i put this together, add me on skype and ill go through it with you.
          Im an Moderator on UnrealSlackers Discord! Which is a Community driven group of likeminded people here to discuss UE4! Join UnrealSlackers on Discord!

          Comment

          Working...
          X