我的游戏拥有玩家x,y,z坐标以及我的玩家相机偏航(仅偏航,不滚动或俯仰)以及敌人x,y,z坐标列表。我想实施目标协助,但是我很难提出这个算法。目标援助 - 我如何选择瞄准哪个玩家?
我不知道如何做到这一点。找到最近的敌方玩家很容易,但是如果玩家想要瞄准比距离最近的敌方玩家更远一点的玩家并且将他们的目标指向非常接近该玩家?我不得不以某种方式做偏航差异的东西,但我不完全知道该怎么做
我有什么,到目前为止,在伪代码:
EnemyList[Enemy1, Enemy2, Enemy3, Enemy4, Enemy5];
Player;
nearestEnemy = Player.FindNearestEnemy(EnemyList);
// in degrees, the "difference" in yaw between the players current aim and the aim they'd need to target the player
yawDiff = Player.YawDiff(nearestEnemy);
if Player.InRange(nearestEnemy) {
Player.Aim(nearestEnemy);
}
我需要做什么yawDiff ,我想,但不知道究竟是什么。