The Behavior tree in unity-tracking

Source: Internet
Author: User

In the game, in order to make the enemy more intelligent or "IQ" higher, we introduced the concept of behavior tree, what is the behavior tree? The simple understanding is that the other side will act in response to each other's actions when one is acting, as if it were a tree, and when the trunk moved, the branches and leaves would move accordingly. Now we apply its theory to our game and use it to track players, first of all we want to clear the target: the following:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/58/57/wKiom1SulLSjjD3gAAC3Db5jEWc480.jpg "title=" 1.png " alt= "Wkiom1sullsjjd3gaac3db5jewc480.jpg"/>

You see, with the arrow is the target point, 22 is based on the target point of movement to take corresponding behavioral tracking. Let's show you a few more pictures:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/58/57/wKiom1SulUSBJSdtAADaGZaSkUk316.jpg "style=" float: none; "title=" 2.png "alt=" Wkiom1sulusbjsdtaadagzaskuk316.jpg "/>

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/58/53/wKioL1SulgeibqHoAACnZC8UEK8238.jpg "style=" float: none; "title=" 4.png "alt=" Wkiol1sulgeibqhoaacnzc8uek8238.jpg "/>

Different moving positions, each other's boats make corresponding changes.

Next we implement the code, first we need to know whether the target is within our traceability range:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/58/53/wKioL1SulvjjrsrwAAHYweucRU8979.jpg "title=" 6.png " alt= "Wkiol1sulvjjrsrwaahyweucru8979.jpg"/>

Next we need to determine how to track.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/58/57/wKiom1SultrAwK9eAAEBcTpab90401.jpg "title=" 7.png " alt= "Wkiom1sultrawk9eaaebctpab90401.jpg"/>

Finally, the following function is implemented to move to the target point.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/58/57/wKiom1SulzaSW0huAAE-iRn0rb4943.jpg "title=" 9.png " alt= "Wkiom1sulzasw0huaae-irn0rb4943.jpg"/>


I am here simply to explain to you, if the real implementation of a lot of things to do. The above is the tracking behavior tree, that is, when the player is moving, the enemy will be based on the player's direction to make corresponding judgments.


This article is from the "Kaiyukan mobile" blog, so be sure to keep this source http://jxwgame.blog.51cto.com/943299/1600892

The Behavior tree in unity-tracking

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.