【发布时间】:2016-08-02 08:51:27
【问题描述】:
我的游戏有玩家 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 做点什么,但不确定具体是什么。
【问题讨论】:
标签: game-physics