自动行为操控Steering(六)—逃避(与拦截方向相反,单体操控)
来源:互联网 发布:网络火词2016 编辑:程序博客网 时间:2024/05/16 10:41
图示:
实现:
///<summary> ///逃避 ///</summary> public class EscapeSteering : Steering { public float safeDistance=15; public override Vector3 ComputerFinalForce() { float angle = Vector3.Angle((target.transform.position - this.transform.position).normalized, this.transform.forward.normalized); //if(Mathf.Acos(angle)) //目标距离 float distance = Vector3.Distance(target.transform.position, this.transform.position); //目标速度 float targetSpeed = target.GetComponent<Vehicle>().currentForce.magnitude; //时间 var time = distance / (speed + targetSpeed); //目标在推断时间内行走的距离=速度*时间 var moveDistance = targetSpeed * time; //拦截点位置=目标自身位置+目标在推断时间内行走的距离 Vector3 interceptPoint = target.transform.position + (target.transform.position).normalized * moveDistance; if (distance > safeDistance) return Vector3.zero; //期望=拦截点位置-自身位置 exceptForce = (interceptPoint-transform.position ).normalized * speed; //实际=当前-期望 return (vehicle.currentForce - exceptForce) * weight; } }
阅读全文
1 0
- 自动行为操控Steering(六)—逃避(与拦截方向相反,单体操控)
- 自动行为操控Steering(五)—拦截(单体操控)
- 自动行为操控Steering(二)—靠近(单体操控)
- 自动行为操控Steering(三)—远离(单体操控)
- 自动行为操控Steering(四)—到达(单体操控)
- 自动行为操控Steering(七)—避开障碍物(单体操控)
- 自动行为操控Steering(八)—路径跟随(单体操控)
- 自动行为操控Steering(九)—徘徊(单体操控)
- 自动行为操控(Steering)(一)—框架
- 自动行为操控Steering(十)—聚集(群体操控)
- 自动行为操控Steering(十一)—分散(群体操控)
- unity3d AI 学习--个体行为操控(1)
- unity3d AI 学习--个体行为操控(1)--具体行为类(1)
- unity3d AI 学习--个体行为操控(1)--具体行为类(2)
- (2)PX4开发指南——飞行模式/操控
- 计算机体系结构原理——数据操控(CPU工作原理)
- unity3d AI 学习--个体行为操控(1)--具体行为类(3)-路径跟随和躲避障碍
- VC下操控excel(精典)
- 23种设计模式总览
- Hibernate 使用
- [NOIP2017模拟]Fantasy Strange Tree
- WebSerVerXML解析
- 集合List中的批量删除
- 自动行为操控Steering(六)—逃避(与拦截方向相反,单体操控)
- 一个链表中包含环,请找出该链表的环的入口结点。
- 广东柏文带你走进化妆品OEM的“望闻问切”
- 性能测试常见用语
- 安卓图片反复压缩后为什么会普遍会变绿?
- 普适性的视觉感知与运动感知
- poj2983&&poj1364
- Android6.0 权限后编辑头像功能
- 【云隐课堂】【软件安装】Source_Insight3.5安装步骤