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"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

How to get aicontroller from event beginplay?

alt text

Was following a tutorial for getting an AI enemy to use a behavior tree. The screen shot is from said tutorial which was done in an earlier version. I'm guessing since I am using 4.17 this part has changed. Any help very much welcomed.

Product Version: UE 4.17
Tags:
help.png (446.9 kB)
more ▼

asked Sep 05 '17 at 07:47 PM in Blueprint Scripting

avatar image

AlwaysShady
11 2 3 8

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

1 answer: sort voted first

That is now a pure function.

It can be called from inside a pawn.

Though, I suggest for you to put that code in your AIController. Then just call Run Behavior Tree.

more ▼

answered Sep 05 '17 at 08:21 PM

avatar image

BenVlodgi
2.1k 38 17 52

avatar image AlwaysShady Sep 06 '17 at 12:21 PM

Right I was able to find those nodes just don't know how to go about recreating the image I posted. I am still fairly new to UE4 and blueprints in general so a little more guidance is needed.

avatar image BenVlodgi Sep 06 '17 at 12:33 PM

White lines represent to execution flow, they go from one task to the next. Other colors represent variable data.

Drag the white pin from Begin Play, directly into Run Behavior Tree. Then drag the Return Value pin directly from the Get AI Controller node, into the Target input.

avatar image AlwaysShady Sep 06 '17 at 12:57 PM

alt text

Everything compiles but still can't get the AI to switch from idle to walking, not sure if the screenshot helps.

help2.png (216.8 kB)
avatar image BenVlodgi Sep 06 '17 at 01:20 PM

What does the blackboard look like?

avatar image AlwaysShady Sep 06 '17 at 01:23 PM

alt text

A little more info, I'm working in 4.17 and in the side scroller template.

bb.png (88.4 kB)
avatar image BenVlodgi Sep 06 '17 at 01:26 PM

If you debug the blackboard, does it run?

avatar image AlwaysShady Sep 06 '17 at 01:34 PM

How would I go about doing that? I looked up debugging the black board but didn't get much...

avatar image BenVlodgi Sep 06 '17 at 02:03 PM

Open the black board in a separate window

Start the game

Press ~ to open console and make sure in the separate window , that at the top you have an blackboard instance selected to debug

Now you should see the execution if it was setup right

avatar image AlwaysShady Sep 06 '17 at 02:11 PM

Press ~ to open console and make sure in the separate window , that at the top you have an blackboard instance selected to debug

Not sure what you mean there...alt text

screenshot-1.png (2.2 MB)
avatar image BenVlodgi Sep 06 '17 at 03:54 PM

nvm that, you got it working still.

So the blackboard is running! And your AI is trying to move. Do you have a navmesh for it to pathfind with? Press P to toggle navmesh visibility.

avatar image AlwaysShady Sep 06 '17 at 04:02 PM

Yes the blackboard behavior goes crazy when I play, all the nodes are firing. But the Ai just stays in his idle pose. Pressing P does nothing probably since I dont have a navmesh for it to pathfind.

Been following This tutorail and got up to the 10 min mark before getting stuck.Don't know if that helps any.

avatar image BenVlodgi Sep 06 '17 at 04:42 PM

He's staying put, because you don't have a navmesh for him to pathfind on. So the MoveTo fails instantly, and it cycles through the other nodes and tries again.

In the Tutorial @0:14, you can see that his project has a navmesh bounds already in place.

Nav Mesh Bounds Volume

ue-answerpic36a.png (247.6 kB)
avatar image AlwaysShady Sep 06 '17 at 04:57 PM

Alright so how do I tell the AI to stay in the Navmeshbounds?

BTW thanks so much for walking me through this! Really helping out a lot!

avatar image shotty46290 Sep 06 '17 at 05:30 PM

The AI already knows not to leave the navmesh. That's why he is not moving now. if you were to tell the AI to move out of navmesh he would most likely run to edge of nave mesh and get stuck or not move at all.

avatar image AlwaysShady Sep 06 '17 at 05:42 PM

He doesn't move because he knows not to leave the navmesh and if he was told to move he most likely would get stuck and not move? So how does that help, it was hard to understand what you are trying to say.

avatar image BenVlodgi Sep 06 '17 at 06:53 PM

He's saying, that AI can only move in NavMesh areas. If the game tells the AI to move to a point outside the NavMesh bounds. Then the Ai will probably move as close as it can to the destination area, within the NavMesh.

Add a NavMesh to your level to allow the AI to know where he is allowed to move.

If that solves your issue, could you up-vote my answer, and mark it as the answer? :)

avatar image AlwaysShady Sep 06 '17 at 06:55 PM

Navmesh has been added and had to rework the graph, he moves around the level but now the Ai character "pops" from idle pose to walking. And jumps around from point to point.alt text

fix.png (221.1 kB)
avatar image BenVlodgi Sep 07 '17 at 03:09 PM

So your problem is solved. If you have another question, you should make a new question.

(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