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"

How do I make it so that once all enemies are destroyed, the next wave starts?

It seems pretty simple, but how do I make one wave begin when all enemies of the previous wave are destroyed? I have tried setting this up properly but no success. Can someone help?

Product Version: UE 4.19
Tags:
more ▼

asked Dec 15 '18 at 02:40 AM in Blueprint Scripting

avatar image

Jason0226
5 1 4

(comments are locked)
10|2000 characters needed characters left

2 answers: sort voted first

You will need to have a variable keep track of how many "enemies" you have in your level. Depending on how you get them into your level (dynamic spawning vs placed) there are various ways to get that number ("get all actors" if they are manually placed, or add each to an array during dynamic spawning). Once you have that number, each time an enemy is killed subtract one from the total, then check and see if it equals 0, if yes then you have completed the "wave" and can spawn new enemies, if not do nothing.

more ▼

answered Dec 15 '18 at 03:30 AM

avatar image

Nebula Games Inc
4k 23 9 14

avatar image Jason0226 Dec 23 '18 at 11:56 PM

I tried doing that also but couldnt get it to work. Can you give an example?

avatar image Nebula Games Inc Dec 24 '18 at 12:13 AM

Not at a computer at the moment so I can't but if you upload screen shots of your set up I can attempt to troubleshoot.

avatar image Jason0226 Dec 25 '18 at 12:03 AM

This is what it looks like after I tried to set it up following CoalFireGaming's example which I also wasn't able to get working.

screenshot-3.png (334.4 kB)
screenshot-5.png (485.6 kB)
screenshot-4.png (480.5 kB)
avatar image Nebula Games Inc Dec 25 '18 at 12:59 AM

You need something like this. The first image is built within the "spawning" BP. The second goes within your enemy BP. Each destroyed enemy will reference the spawner and figure out if it was the last enemy killed based on the total number of enemies spawned.

alt text

alt text

phase-1.jpg (129.3 kB)
phase-2.jpg (126.0 kB)
avatar image Jason0226 Dec 29 '18 at 12:47 AM

I got it to where everytime I destroy an actor it subtracts the integer in increments, but I'm trying to make it so that if the increment goes to zero, actors are spawned in. Everytime I reference my spawner it would say that it "Accessed None trying to read property SpawnReference." I also tried it the other way and reference the actor itself from the spawner but that accessed none also. Any idea how to set up the spawner to spawn actors from class when there are none on the map because I tried a couple different ways and couldn't get that part.

avatar image Nebula Games Inc Dec 29 '18 at 01:59 AM

Show me your spawner screen shots and how you decrement your enemy number. You must be deleting the spawner itself somehow which you shouldn't. It should be persistent in your level and have your enemies reference it to determine if they are the last enemy.

avatar image Jason0226 Jan 01 '19 at 12:00 AM

I try to play the function Myfunction from ZombieMakeHuman and the target is Spawn, but that doesn't work. Maybe I didn't set that function up right. Maybe the Event Destroyed in Spawn shouldn't be there.

screenshot-6.png (393.2 kB)
screenshot-7.png (373.5 kB)
screenshot-8.png (566.9 kB)
avatar image Nebula Games Inc Jan 01 '19 at 12:09 AM

Where did you set "spawn reference"?

avatar image Jason0226 Jan 01 '19 at 12:30 AM

I didnt set spawn reference if your talking about get or set. But I think the reason the function "Myfunction" isnt being called properly is because I put it in the ZombieMakeHuman blueprint which it is trying to be called from but cant because the ZombieMakeHuman blueprint actor is destroyed before it is called. Would I set that up in the Spawn blueprint?

avatar image Nebula Games Inc Jan 01 '19 at 12:49 AM

It doesn't work because you never set the spawn reference. If you print a string from the spawn reference I bet it says none....that's why none of this works and you get accessed none errors. You didn't give a direct reference you just made an empty variable container for the spawn type object but never put a specific object in

avatar image Jason0226 Jan 01 '19 at 01:11 AM

The "Spawn Reference" variable is the right "SpawnBlueprint" object reference. It is referencing the "SpawnBlueprint" blueprint. BTW I changed the blueprint name from Spawn to SpawnBlueprint to make sure it was the right thing to reference. That wouldnt change anything else though. Also what would I do now?

avatar image Nebula Games Inc Jan 01 '19 at 01:14 AM

Show me how you "set" that reference

avatar image Jason0226 Jan 01 '19 at 01:31 AM

I drag off from true on the branch in ZombieMakeHuman and type in Myfunction. Then since it needed a reference because the function is in another blueprint, I promoted Target (from the Myfunction connected to branch) to variable which referenced it that way.

avatar image Jason0226 Jan 01 '19 at 01:44 AM

Ill have to get back to this tomorrow , getting off for now. But if you have any idea how to have it work right then please let me know. Thanks.

avatar image Jason0226 Jan 01 '19 at 07:35 PM

Actually I just got it to work right. All I needed was a "Get All Actors Of Class" in my ZombieMakeHuman blueprint for actor class "SpawnBlueprint" and THEN call the Myfunction.

avatar image Nebula Games Inc Jan 01 '19 at 08:02 PM

Haha yea, that would be one way to get the reference. Glad you got it working :)

(comments are locked)
10|2000 characters needed characters left

If you're destroying the enemy actors every time they die then run a "Get all actors of class" every time the enemy dies, and compare the return array to a Length node attached to a branch node where you will have a true and false return. If the length of the return array is == (equal to) the specified number you're comparing against, then do something. Here's a small example.

Edit When you run the "Get All Actors of Class" node, it only gets actors that are spawned in the world. So as long as that number is less than or Equal to the number you want, to spawn the next wave. It'll do whatever you want it to do, off the "True" pin on the Branch Node.

alt text

screenshot-9.png (933.6 kB)
more ▼

answered Dec 24 '18 at 02:15 AM

avatar image

CoalFireGaming
236 2 5 5

(comments are locked)
10|2000 characters needed characters left
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