官术网_书友最值得收藏!

Choosing transitions

At this point, we have to make some design and logic decisions regarding the way our states will flow into each other. When we map out these transitions, we also want to keep in mind the conditions that trigger the transitions to make sure they are logical and work from a design-standpoint. Out in the wild, when you're applying these techniques on your own, different factors will play into how these transitions are handled. In order to best illustrate the topic at hand, we'll keep our transitions simple and logical:

  • Patrol: From patrol, we can transition into chasing. We will use a chain of conditions to choose which state we'll transition into, if any. Can the enemy tank see the player? If yes, we go to the next step; if not, we continue with patrolling.
  • Chase: From this state, we'll want to continue to check whether the player is within sight to continue chasing, close enough to shoot, or completely out of sight—that would send us back into the Patrol state.
  • Shoot: As earlier, we'll want to check our range for shooting and then the line of sight to determine whether or not we can chase to get within the range.

This particular example has a simple and clean set of transition rules. If we connect our states accordingly, we'll end up with a graph looking more or less similar to this one:

Keep in mind that the placement of the nodes is entirely up to you, and it does not affect the functionality of the state machine in any way. You can try to place your nodes in a way that keeps them organized so that you can track your transitions visually.

Now that we have our states mapped out, let's assign some behaviors to them.

主站蜘蛛池模板: 政和县| 桃园市| 醴陵市| 瑞丽市| 平远县| 新建县| 大丰市| 双峰县| 嫩江县| 哈巴河县| 托里县| 灵川县| 洪雅县| 凤台县| 巴南区| 松江区| 耿马| 望奎县| 建始县| 天水市| 鄂尔多斯市| 孙吴县| 宜宾县| 平泉县| 潞城市| 泸水县| 南漳县| 荥阳市| 榆林市| 腾冲县| 凌云县| 南开区| 九龙城区| 尼勒克县| 易门县| 亚东县| 咸阳市| 临夏市| 盱眙县| 嫩江县| 左贡县|