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"

Get all actors of class not getting all actors in level

So right now I have run into a problem in my paper2d project. It seems as if the get all actors of class are not getting all actors of class. I have two instances of an AI character in my game and right now I have it set up to where if on overlap is enemy then damage the enemy. Well it will only damage one of the enemies and none of the others. Below is how I am calling all actors of class.

alt text

Product Version: Not Selected
screenshot (11).png (734.3 kB)
more ▼

asked Nov 25 '15 at 04:01 AM in Blueprint Scripting

avatar image

38 21 17 21

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

1 answer: sort voted first

Instead of just using a 'Get' element at index 0, from the array output of 'Get All Actors of class', try connecting the output to a For Each loop and then for each element in the array, apply damage.

more ▼

answered Nov 25 '15 at 06:13 AM

avatar image

1k 83 75 118

avatar image ThatGuyMiniB Nov 26 '15 at 01:46 AM

Ok so I tried doing this and it still isnt registering for other instances in the level of the enemy. What am I doing wrong lol.

alt text

screenshot (12).png (792.8 kB)
avatar image Stormrage256 Nov 26 '15 at 05:32 AM

After the for loop, you're storing all instances onto the same 'EnemyRef' variable. So what ever was stored in it before that gets erased. Instead try adding them to an array. Then once the for loop is completed, you can check out the array length to see if all enemy units are accounted for. Same for your Smart Enemy Blueprints as well with a separate array and for loop.

avatar image ThatGuyMiniB Nov 26 '15 at 09:32 PM

You mean kind of like this?

alt text

liketihis.png (432.7 kB)
avatar image Stormrage256 Nov 27 '15 at 12:12 PM

Instead of using make array in the for loop execution, get use 'Enemy ref array' and use the 'Add' function for arrays. This way as the for loop executes, you can add each Array Element from the loop into your Enemy array one by one.

avatar image ThatGuyMiniB Nov 29 '15 at 05:18 AM

I am still getting confused by this because how would I reference an actor from the array for an oneventoverlap if actor == this object then kill type of thing.

avatar image Stormrage256 Nov 29 '15 at 06:54 AM

You could get your player character, cast it to your PlayerBP, and then get the Enemy ref array that you've stored above. This can be done from any other blueprint. Once you have the array, just check if the particular enemy actor is in the said array by using the 'Contains Item' node for the array. You can check out all the array functions in the documentation: Array Nodes. It would probably ease out the learning process if you know the built in array nodes that you can use to your advantage.

avatar image ThatGuyMiniB Nov 30 '15 at 10:20 PM

Sweet! I got that part to work now I am trying to have it so when the actor that is being referenced is destroyed delete it from the array.

(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