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"

One blueprint for multiple AI.

Hello everyone. I tried to explain the thing I struggle at the picture a posted. I know I had to do something with Parent/Child classes and array structures but i really can't figure out how am i going to do that. I really need your help. Thanks to all of you <3 alt text

Product Version: UE 4.19
Tags:
bp.png (77.9 kB)
more ▼

asked Sep 03 '18 at 11:58 AM in Blueprint Scripting

avatar image

anil021
13 1 4

avatar image ThompsonN13 Sep 03 '18 at 01:10 PM

i think im reading this right, you want when the enemy is behind something for them to move toward the player right? and your plan for this was to use a line trace to determine if the player can see them. if thats all true then you want something like the below example. in the example you first get a list of all the enemies, i did this via a get all actors of class but you will want to make this a variable array if you plan to call it often. then for each enemy in the array i used a line trace to determine if there was anything between them and the player. if there was something between them aka a hit then the return value will be true and we call the start event in the specific enemy we were testing.

you could also do this in the enemy instead which would avoid the need for an array.

alt text

capture.png (150.0 kB)
avatar image anil021 Sep 03 '18 at 08:51 PM

Thanks for answer. That's exactly what i wanted to do but i already did it. The problem is, when i add more than 1 BP Enemy to level, when one of them behind the wall, all of them starts to move to player not only the one which is behind the wall. I solved it by making different BP for each enemy but it really kills the performance. What should be the rule in the BP_Enemy blueprint for making the only one Enemy move towards to player even if i duplicate the same blueprint for creating multiple enemies in my level. alt text

movetoactor.png (160.4 kB)
avatar image ThompsonN13 Sep 03 '18 at 09:58 PM

if you did it the way that i showed then you would be calling the movement event aka the start event on only one enemy. so it isnt possible that it would effect them all.

also what do you mean you created a bp for each enemy? are you saying that you made each enemy its own actor class? thats just bad on so many levels. all you need is one class for an enemy (if they are to be the same type), then you use the script to affect only the instance that you want. this is why i used the for each loop in my example. the for each loop gets each individual instance (enemy placed in the level) and runs the script for only that one enemy, then it repeats the process for all the others. so to summarize the above script its like the character asking ok enemy one can i see you, no then im telling you to start moving, yes then do nothing. ok we are done with enemy one now ask enemy two can i see you.... etc etc for each enemy.

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

0 answers: sort voted first
Be the first one to answer this question
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