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"

AI That Learns from mistakes

Is it possible to make a AI that learns from your mistakes and can set down traps, set up cameras. I cannot find a tut to make that kind of AI. Is it blueprint or c++? Thanks

Product Version: UE 4.19
more ▼

asked Jun 10 '18 at 10:53 PM in Blueprint Scripting

avatar image

1 1 3

avatar image ThompsonN13 Jun 10 '18 at 11:56 PM

thats pretty high level stuff. your not likely to find a tutorial on it that is specifically in ue4. i know theres whole youtube channels about ai learning so do some googling and learn their methods and algorithms you may have to do the coding yourself though.

avatar image Jack Gelafko Jan 29 '19 at 01:50 AM

Hello Neighbor Style?

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

3 answers: sort voted first

Yes, It is very possible using workarounds. You can set up this "intelligent" ai by using simple "if" statements around player behaviour etc. For example, every time the player hides, save a vector with that location and the number of times he goes there if it is the same location. If the player hides there 3 times or more, make the AI go to that location to check it. Same deal with the windows/doors. Check how many times the player goes through that window/door (Use triggers/collision). The more the player goes through that window/door, the higher chance the AI will board it up. There is no single tutorial that will help you do this, but it is possible using multiple systems.

Let me know if this is helpful!

more ▼

answered Jun 12 '18 at 10:03 AM

avatar image

16 1 6

avatar image CyberFoxyYT Jun 12 '18 at 05:39 PM

Thanks I will try this

avatar image CyberFoxyYT Jun 12 '18 at 06:03 PM

Could you do a small tutorial on what you mean I am a bit confused on what to use and where to put it. Sorry

avatar image e3pojedi Jun 13 '18 at 10:53 AM

Here are some blueprint examples. alt text

You will need to set up a savegame object and make some variables inside it. The above script is for the window/hiding place, as you can use triggers and check if the player is inside it.(OnComponentBeginOverlap). If they are, it will use some logic to save that location and the number of times. You could replace the vector with a reference to the window/hiding place. alt text

This is for the AI to check the hiding place, by going to it. You will need to make your own script for boarding up windows or opening doors, but this should go a long way for now.

I have not been able to try this, so let me know if it works!

10.png (106.9 kB)
11.png (134.4 kB)
avatar image CyberFoxyYT Jun 13 '18 at 06:11 PM

Thanks I will try this :3

avatar image CyberFoxyYT Jun 14 '18 at 01:18 AM

Just tried to do that I am stuck however how did you do the two variables in one target and name I cannot find it. Sorry I am so excited to try this but it won't work if I don't do that

avatar image e3pojedi Jun 14 '18 at 07:36 AM

Go to your savegame and make a variable. It could either be a vector (the one I have shown) or an actor reference (takes a bit more setting up). Then click on the yellow oval next to the type of variable, and select Map/Dictionary (the last one). Then make the right variable an integer. Let me know if the system works! alt text

alt text

17.png (18.9 kB)
18.png (14.6 kB)
avatar image CyberFoxyYT Jun 14 '18 at 06:51 PM

So are these nodes for the ai character or trigger box also how to do set variables

avatar image e3pojedi Jun 14 '18 at 08:56 PM

When you drag a variable from the left side, it will give you the option to either get or set the value of it. You can also right click in the event graph and type "Get/Set (variable name)". In this case, drag out a pin from the savegame and write "Get location" (or whatever the name of the variable is). The first image is for the trigger, but the second image is for the AI. and the 3rd/4th images are for the savegame. So you would need to drag out a pin from the "Get" of the location and write "add" to come up with the "add" node (the first image).

Hope this helps!

avatar image CyberFoxyYT Jun 14 '18 at 11:23 PM

ok thx. Btw how did you combine the target and location into one variable?

avatar image CyberFoxyYT Jun 14 '18 at 11:23 PM

Pls reply soon

avatar image CyberFoxyYT Jun 14 '18 at 11:38 PM

Nvm about the combination of variables I solved it thx anyway

avatar image CyberFoxyYT Jun 15 '18 at 04:47 PM

It did not work

avatar image CyberFoxyYT Jun 15 '18 at 05:27 PM

I am using AI perception not pawn sensing, and I am also using behavior tree. maybe that is why it's not working because you used a AI moveto I don't have that in my AI

avatar image e3pojedi Jun 16 '18 at 05:47 AM

It probably is, as you need to include a "Move to" otherwise it will not work at all. Try without behaviour trees first, and the AI Perception should have nothing to do with it, as the first image is for the triggers to work, and the second image is for the AI to work.

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

Yes, although it depends exactly what you want.

If you want it to 'truly' learn from it's mistakes and adapt dynamically then this will probably be a very complex system and you'll probably need to write most of it yourself (there may be some libraries you need to use). I certainly wouldn't suggest attempting this with blueprints, although it might be possible (but slow).

However, the alternate and usual "game" way of handling this is to look for specific triggers / patterns performed by the player and if they are seen, your Behaviour Tree can trigger some other action. For example, it could know if a character kept going down a certain passageway (by setting up collision triggers) and if that occurs a certain number of times, the behaviour tree might then instruct the AI to go and set a trap in that passageway,

This second way gives the illusion of learning, although it's really only adapting based on pre-programmed rules. Probably enough for most games and will probably give a more satisfying "game play" than any real AI learning system (at least for now). This will still be quite complex to create though and I recommend writing down everything you want it to achieve before you start implementing anything.

more ▼

answered Jun 11 '18 at 08:54 AM

avatar image

1.1k 4 6 12

avatar image CyberFoxyYT Jun 11 '18 at 08:50 PM

I want the ai to set up a bear trap at the front door or windows, board up windows and put a chair up against the door. Also I want it to search inside cupboard and under bed. If the player is hiding in these places he will kill them, if he checks and the player isn't there he will just leave. Btw Thx for the answer

avatar image phil_me_up Jun 12 '18 at 06:19 PM

That doesn't sound too much like learning from mistakes, so I think you can absolutely do what you want. I'd strongly recommend using Behavior Trees for this. These help provide a set of rules for your AI, but they are quite flexible.

A bit more information about Behavior Trees in Unreal can be found here: https://docs.unrealengine.com/en-us/Engine/AI/BehaviorTrees

I recommend being patient. Nearly everyone who is new to behavior trees will get it wrong the first few times because it requires a certain way of thinking, Start small and build up!

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


Its not UE4 but this Unity video includes a project for download. see 54:29. I assume it is C# but you could take it's logic and transfer it into Unreal.

It is very interesting stuff!

Hope it helps.

more ▼

answered Jun 12 '18 at 07:18 PM

avatar image

8 1 2 4

(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