鱼群算法在捕鱼达人类似的游戏中是不可或缺的,还有很多项目中都要用到,我本人觉得这条算法帮助我做过诸多的项目,其中有AR,VR,捕鱼达人秀等,简单粗暴,如果有需要改正的地方还请大佬们指正:
public class TankGroup : MonoBehaviour {
private static List tankGroups;//所有组
public LayerMask mask;//成员层
public int groupID=0;//组id
public float keepDistance=10, keepWeight=1;//成员保持距离和保持距离权重
public float targetCloseDistance=20,targetWeight=1.25f, moveWeight=0.8f;//距离目标距离,距离目标权重和成员移动权重
}
坦克成员
public class TankBehaviour : MonoBehaviour {
private const float minMoveCheck=0.2f;
public int groupId=0;//组 id
public float moveSpeed=5, rotateSpeed=20;//移动旋转速度
public Vector3 position{
get{
return transform.position;}
}
public Vector3 movement{
get{