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 to end level after all enemies are destroyed - It end after 1 enemy has been destroyed

Currently I am trying to "restart the game" once all 10 enemies on the game have been destroyed. But from reading a similar question to solve this I have only become confused. https://answers.unrealengine.com/questions/199432/how-to-end-level-after-all-enemies-are-destroyed.html At the moment this process works but it restarts once only 1 of the 10 enemies have been destroyed... Any solutions?alt text

Product Version: UE 4.8
Tags:
1.png (368.7 kB)
more ▼

asked Jun 29 '15 at 07:44 AM in Blueprint Scripting

avatar image

Santeon
18 5 6 7

avatar image Santeon Jun 29 '15 at 11:08 AM

Thanks Pete, I'm still learning my ropes around unreal engine blueprints. What you have said is what i'm trying to do. Let's say I have 10 enemies and each time 1 of these actors are destroyed the ReduceEnemyCount will take away 1 from the total amount of points (10) How do I do this because i'm still playing with values with no difference, any solutions, or am I missing a big part of this? Thank you!

avatar image PeteX Jun 29 '15 at 03:55 PM

Start by looking at the Set Enemy Count node. At its bottom left you have some nodes which give the new value for Enemy Count. Those nodes start with the old value of Enemy Count, and subtract ten from it. This means that you'll start with Enemy Count set to ten, and then the first time Reduce Enemy Count is called, it will change to zero.

From the bit of blueprint you posted it's hard to be sure, but you also need to make sure you are setting Enemy Count to ten at the start of the level.

avatar image Santeon Jun 30 '15 at 01:57 AM

Thank you very much for your patience and time. I understand what you are talking about but with only 1 issue. I believe the game dosnt register the 2nd - 10th enemy as a value, and stops counting down after the first destroyed actor. This is shown when I change the value in the SetEnemyCount Node it counts the death of only 1 actor not the others. I know this may be irritating but if you could help me out it would mean so much! Thank you.alt text

alt text

3.png (379.8 kB)
4.png (374.1 kB)
avatar image PeteX Jun 30 '15 at 08:53 AM

If you right-click the Set Enemy Count node, you will have the option of setting a breakpoint. That means execution will stop every time that node is entered. It might be worth trying that, and looking to see for example: whether the node is actually entered for each enemy; what the value is before it is updated; and what the final value is.

avatar image Santeon Jul 01 '15 at 01:12 AM

Currently all this data such as "SetEnemyCount and ReduceEnemyCount" is stored inside the enemy. I have tried the breakpoint with no result. Unless I'm missing the picture the game dosnt want to count the second death and onward. Preventing me to have a working restart system. If you don't understand what I mean I can try to make a video making an example of these numbers and show their results.

avatar image gloim Jun 30 '15 at 05:27 AM

I dont know if I missunderstand something but where do you store the EnemyCount Variable? Just to make sure that its not stored in your BasicEnemy BP. And as Pete said, make sure you set the variable because the default value is 0.

avatar image gloim Jul 01 '15 at 03:09 AM

Well, you should store them in some other place because you destroy the BP and the stored variables ;)

avatar image Santeon Jul 01 '15 at 04:24 AM

Sorry still new to unreal and didn't realize the entire BP would be destroyed after only 1 actor is destroyed. Anything you can tell me of how to store it in another BL, because I made a new BP and it dosnt recognize it within the main actor's BP.

avatar image Santeon Jul 01 '15 at 04:24 AM

Also thank you so much for the amazing feedback, was not expecting a ceent and you both have been awesome :D

avatar image Santeon Jul 01 '15 at 09:43 AM

Ok, so I have now redone this BP inside a GameMode BP, but no difference. Should I be storing these variables somewhere else or is the BP no set up correct? :/alt text

5.png (279.8 kB)
avatar image PeteX Jul 01 '15 at 10:13 AM

The Cast to Game Instance node isn't being used correctly. At the moment I think it probably takes the Cast Failed track each time, which is the reason why nothing happens.

However... If you're already in the Game Mode blueprint, that's fine. There is one Game Mode per level, so it's a perfectly good place to track the enemy count. The thing you mustn't do is track the count in the enemies' own blueprints, because those blueprints exist separately for each enemy. When you destroy an enemy, you would destroy the count too.

I wonder if you might have misunderstood this feature of blueprints. Blueprints have logic (the nodes you place with the blueprint editor) and data (variables like the enemy count). When you have a blueprint for an enemy, the logic is shared between all enemies, but the data is private to each individual enemy. The idea is that the enemies can be doing different things based on the data (enemy one is hitting you, enemy two is patrolling) but the logic is the same. The logic needs to be the same, because in other circumstances, enemy two will hit you. You don't want to have to write the logic for that over and over again, for every enemy.

avatar image Santeon Jul 01 '15 at 11:26 AM

From what you told me I now understand a bit more about actor BP's and I thank you! For now I need to solve this remaining bit of BP, for I need to figure out how to make the subtraction (BP) activate once the actor has been destroyed. Although I knew how to do it before, it's a bit more different due to the new BP (GameMode). Thanks alt text

6.png (286.8 kB)
(comments are locked)
10|2000 characters needed characters left

3 answers: sort voted first
more ▼

answered Jul 25 '15 at 12:14 PM

avatar image

Fanto88
310 23 15 27

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

When you get the ReduceEnemyCount event, you are subtracting ten from the Enemy Count variable. That means it will be zero straight away, and the level will end. I imagine you intended to subtract one for each ReduceEnemyCount event, so it would get to zero after that event had been called ten times.

more ▼

answered Jun 29 '15 at 09:41 AM

avatar image

PeteX
173 5 9 13

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

I would store important gamevariables in gamemode or gamestate, depending on what kind of game you are working on.

more ▼

answered Jul 01 '15 at 09:09 AM

avatar image

gloim
169 4 9 21

(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