Maibu ----- UE4AI automatic patrol and attack

This behavior tree gave me nausea and vomiting all, I use the 4.24, followed by the official website did not reach the results, along with the video do not reach that effect, and I get very impatient, and finally the whole out today a. In some places with a bit of my own logic. // rely on you for the tutorial, we have brains to think for themselves, the ability to exercise independent coding, not "excessive" reliance tutorial to learn by analogy

I use the third person Templates

OK, I'll give you talked about from 1 8, wherein a futile

First first, which is the behavior of a tree service,

ps: Tree Service does not know what the behavior, then refer to the official document: https: //docs.unrealengine.com/zhCN/Engine/ArtificialIntelligence/BehaviorTrees/BehaviorTreesOverview/index.html

The logic inside me when you say something, the players get the coordinates, coordinates AI, AI players to coordinate subtraction draw a line, the last one, is like asking what Nor ......, we remember him Nor, is this co a vector,

After the front to coordinate, Forward, two stuff dot, i.e. dot, then to inverse cosine value, determination is within 55 ° angles, if a branch is provided

If so, then see the players, using Chase (Attack), and if not, using not chase (Idle)

ps: Without knowing the dot: https: //blog.csdn.net/kebu12345678/article/details/80724336 this blog can reference.

Second, blackboard node: TargetActor, Object type, to be set under the Actor; enumerated types: the purpose of the definition of AI to attack or not to attack (on patrol), two states, Idle, Attack, are enumerated type

Then the first blueprint, a blueprint for the behavior of tree service you can set the value of the blackboard, blueprint SetBlackBoardASObject, create a new variable of type BlackBoardKey, name TagetActor, put it on and even blueprints SetBlackBoardASObject key, there is a Object is GetPlayerCharacter, I was written from memory may not be correct, even put it on and Object.

Set enumeration, SetBlackBoardAsEnum, enumerate confirm the use of the chart on the board 5, which is AI_Enum, select the option to enumerate Attack, not idle. Because the players have been found, it should be attacked

Forget that first call is the beginning of the event Tick AI, I was written from memory, update AI per second,

If false in that branch, repeat the above, call Idle, as if there is an event, call the AI ​​again, it seems that starts with A, A ...... AI event ......

There is another call again SetBlackBoardAsEnum Idil

Here set the speed, because I am a dictation, so the idea to write it down:

First First GetMovementComponent, castToMoveComponentCharacter, SetMaxWalkSpeed,

 

I have a headache headache here, because I set up a separate speed task, or function, pathfinding is not successful, so I gave it to set up to service it.

This is the behavior of the tree, I chase the player and patrol behavior tree,

Fourth, control blueprint, which must take AIcharacter class of AI-controlled changed this our new AI control, this is my AI_Controller, then set the top of the details panel should be able to see the icon in the assembly, the first eight is my character, I put a third person who gave a copy, and then empty the inside of the event. I gave the camera and deleted the spring arm.

Controls need to write a blueprint EventBegin, is the default top three events that make RunBehaviourTree connection with him.

Do not forget to BehaviourTree to our new Tree, this is my AI_BT, blueprint nodes have the option to choose our blueprint to build on it

The first six patrol, I do not write, too tired to talk about the focus of the figure.

 

 

Mainly used MoveToLocation, move to the coordinates, the following three are moving into the detection did not succeed, after the success, FinishExcute the end of the event, I feel no need, the end of the event had a direct

ReceiveExcuteAI, this node is the task runs, is the behavior of the tree refers to your departure time to the task, the top four is to set the speed, the GetRandomLocation ... is to get random coordinates,

我直接用ActorLocation。

上面那个树节点MoveTo是移动到,选择器上的装饰器设置如下:

开发一定要自己动脑,不要“过度”依赖教程

后记:Nav...mesh打头的在编辑器界面左面搜索,这个是路径追踪,让它覆盖游戏中的所有物体,然后按下P键即可设置完毕,设置完是绿色的。

Guess you like

Origin www.cnblogs.com/tilyougogannbare666/p/12078558.html