Unity行为树插件Behavior Tree Designer记录.Decorator装饰5

TaskGuard在Unity的行为树中起到资源限制作用,防止如动画播放等任务被过度使用。它类似信号量,确保同一时间只有一个任务能执行特定操作。TaskGuard允许指定同时访问次数,超过限制则后续任务需等待或跳过。实现原理通过CanExecute检查执行计数,并在任务开始和结束时调整计数。此外,通过LinkTask引用其他任务,实现任务间的交互。尽管可以通过共享变量轻易实现相同功能,但官方TaskGuard设计选择了当前方式。
摘要由CSDN通过智能技术生成

TaskGuard

The task guard task is similar to a semaphore in multithreaded programming. The task guard task is there to ensure a limited resource is not being overused. For example, you may place a task guard above a task that plays an animation. Elsewhere within your behavior tree you may also have another task that plays a different animation but uses the same bones for that animation. Because of this you don't want that animation to play twice at the same time. Placing a task guard will let you specify how many times a particular task can be accessed at the same time. In the previous animation task example you would specify an access count of 1. With this setup the animation task can be only controlled by one task at a time. If the first task is playing the animation and a second task wants to control the animation as well, it will either have to wait or skip over the task completely.
task guard任务类似于多线程编程中的信号量。task guard任务用于确保有限的资源不会被过度使用(

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值