我正在开发一款 Android 2D“太空战士”游戏,我现在正在开发 AI。
AI(敌人)以一定的速度 V1(V1x,V1y)移动,它想要调整这个速度,以便它以最大速度匹配截距向量。
我知道拦截速度是可以实现的:
V_intercept = (player.x - enemy.x, player.y - enemy.y)
normalize(V_intercept)
V_intercept.x *= MAX_SPEED
V_intercept.y *= MAX_SPEED
我正在寻找的是一种找到单一速度的方法v_correction
,当应用t
时间时,它将使敌人以正确的速度朝向玩家。
我想我正在寻找2个功能:
getCorrectionVelocity(current_velocity, desired_velocity, acceleration) // not sure if acceleration is even needed here
getTimeToReachVelocity(current_velocity, desired_velocity, acceleration)
笔记:
质量和转向时间不相关。想象一下所有质量 = 1,转向某个方向的时间 = 0
此外,我将在 AI 的其他部分需要这些方法(例如,计算敌人将其速度与玩家的速度相匹配所需的时间),因此我需要它们是通用的,这意味着能够计算我给他们的任何速度的校正和时间。
提前致谢!