我正在开发一款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时间时,它将使敌人以正确的速度朝向玩家。
我想我要找两个函数:
getCorrectionVelocity(current_velocity, desired_velocity, acceleration) // not sure if acceleration is even needed here
getTimeToReachVelocity(current_velocity, desired_velocity, acceleration)注意:
质量和转向时间不相关。假设所有质量= 1,转向某个方向的时间=0
此外,我还需要在AI的其他部分使用这些方法(例如,计算敌人需要多长时间才能将其速度与玩家的速度匹配),因此我需要它们是通用的,这意味着能够计算我给他们的任何速度的校正和时间。
提前感谢!
https://stackoverflow.com/questions/23915955
复制相似问题