我的遊戲擁有玩家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 ,我想,但不知道究竟是什麼。