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"

I need to make a variable for the amount of enemies in the level

I need to make a variable for the amount of enemies in my level, the enemies spawn endlessly in a bounding box using an integer in a random range. This is why I can not just add X amount of enemies to the variable each spawn. Does anyone know how I can use the random number the engine picks as the number to add to the variable?

I am using blueprints to make the game.

Any help would be greatly appreciated.

Product Version: UE 4.9
Tags:
more ▼

asked Dec 15 '15 at 12:10 PM in Blueprint Scripting

avatar image

MCMurray
1 1 1

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

2 answers: sort voted first

Hi man your question is not fully clear so if i misunderstood , just rewrite your question more clearly.

You have a box , in wich you want to spawn endlessy a number N of monsters. N is a random number in a range. Like spawn every 10 seconds 2-5 ghost

So you should build up a function or a event "Spawn enemies" the first thing is set your number of enemies, so take the "random int in range " node and calculate with some literal values or variables, the right amount of enemies you want to spawn. Lets say i am at level 3 , so i want to spawn at least 1 ghost for lever and max 3 ghost for level of difficult. Once you have completed the random in range you can use his output as number of iteration in loop. Take the loop node and pin in the last index. Now in the loop body build up your spawning . be carefull that spawn all ghost in same location may cause troumble.alt text
Hope this help :)

more ▼

answered Dec 15 '15 at 01:40 PM

avatar image

Est_engine
1.2k 58 12 62

avatar image MCMurray Dec 15 '15 at 01:49 PM

Thanks for your help but I have already got the enemies spawning but I want to control the amount that can be in the level at a given time.

The blueprint I created spawns between 2 and 6 enemies so I want to add the number the engine picks to a variable each time a group is spawned because it is random I can not just add X amount to variable each time it they are spawned,

If I could get the variable to see the number the engine is picking and add that to the current number of enemies variable I will be able to use a branch to stop the spawn when 50 enemies are in the level.

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

Oooo.... Maybe i get it now , You want know how many enemies you have already spawned to stop spawning? There is a node called "get all actor for class" or "get all actor with tag". These will give you an array ,with all the "enemies" you just get his "lenght" . So IF ( get all actor of class "Monsters" )Lenght is < of 50 , SPawn monsters otherwise, not spawn.

more ▼

answered Dec 15 '15 at 03:20 PM

avatar image

Est_engine
1.2k 58 12 62

(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