/// <summary> /// 这样做并不是很好,后面的处理碰撞预测,和碰墙预测,就搞不好了。 /// 建议还是改成,将Target作为结构体出现,并且,增加GetTargetFormGameObject和ApplyTargetToGameObject两个方法 /// 用来驱动Unity的GameObject行动,这样还可以做到,完全的,游戏逻辑和显示层分离。先不写了,整理代码的时候,在搞这块 /// 我要丰富一下Apex和BehaviorDesigner的算法 /// </summary> /// <returns></returns> protected override float CalculateOrientation() { //更新蜿蜒朝向 wanderOrientation = SteerUtils.RandomBinomial() * wanderRate; //计算蜿蜒方向,相对于当前朝向的方向。 target_orientation = wanderOrientation + character.orientation * Mathf.Deg2Rad; return(target_orientation); }
public bool GetSteering(out KinematicSteeringOutput output) { //get Velocity form orientation output.velocity = max_speed * SteerUtils.OrientationToVector3_XZ(character.orientation); //Q:每帧都变吗,不会有问题吗?GetSteering不是应该每帧都调用的吗啊?还是可以隔一段时间调用过一次? output.rotation = SteerUtils.RandomBinomial() * max_rotation; return(true); }