如何制造“拦截导弹"?玩游戏? [英] How to create an "intercept missile" for a game?

查看:147
本文介绍了如何制造“拦截导弹"?玩游戏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一款游戏,其中装有寻的导弹.目前,他们只是转向目标,这产生了相当愚蠢的效果,所有导弹都跟随目标.

我想创造一种更具致命性的导弹,将目标对准目标到达"时的位置,而我对此却有些困惑和困惑.

我猜测我将需要确定将来目标的位置(无论如何还是要猜测),但是我无法确定前进的方向.它需要基于导弹距目标多远的距离,但目标也要移动.

我的导弹具有恒定的推力,但转弯能力却很弱.希望他们会很快又令人兴奋,但要像母牛一样转弯(即,对于在那里的非HitchHiker粉丝来说是非常糟糕的事情).

无论如何,对于Stack Overflow来说,这似乎是一个有趣的问题,可以帮助我解决问题,因此,对于更好或更有趣"的导弹的任何想法或建议都将不胜感激.

接下来将是AI来躲避它们...

解决方案

您建议使用的是命令指导",但是有一种更简便,更好的方法.

真正的导弹通常这样做的方式(并不是所有人都一样)是使用一种称为比例导航的系统.这意味着导弹以与导弹和目标之间的视线(LOS)转向相同的方向转向",其转向速率与LOS速率成正比" ...要求当LOS率为零时,您就在碰撞过程中.

您可以通过比较导弹与目标之间的直线斜率(从一秒到下一秒)来计算LOS率.如果该坡度没有变化,则说明您正在碰撞过程中.如果变化,请计算变化并按比例的角速度旋转导弹...您可以使用代表导弹和目标位置的任何度量.

例如,如果使用2的比例常数,并且LOS以2度/秒的速度向右移动,则将导弹以4度/秒的速度向右旋转. LOS以6度/秒的速度向左移动,导弹以12度/秒的速度向左移动...

在3-d问题中,除了"LOS率的变化"(以及由此产生的导弹转弯速率)本身是一个矢量外,它是相同的,即,它不仅具有大小,而且具有方向(我是否将导弹向左转) ,向右或向上或向下或与水平线成30度以上的角度,以此类推……等等……想象一下,作为一名导弹飞行员,您将在其中设置机翼"以施加升力…… 雷达制导导弹,知道"闭合速度.根据关闭程度调整比例常数(关闭程度越高,导弹尝试旋转的速度就越快),这样,在高关闭情况下(飞行时间越短)导弹会越积极地旋转,而在低关闭情况下导弹的攻击就越少(尾巴追逐)何时需要节约能源. 其他不知道闭合程度的导弹(例如响尾蛇)使用的是恒定的预定比例值. FWIW,越南时代的AIM-9响尾蛇使用的比例常数为4.

I have a game I am working on that has homing missiles in it. At the moment they just turn towards their target, which produces a rather dumb looking result, with all the missiles following the target around.

I want to create a more deadly flavour of missile that will aim at the where the target "will be" by the time it gets there and I am getting a bit stuck and confused about how to do it.

I am guessing I will need to work out where my target will be at some point in the future (a guess anyway), but I can't get my head around how far ahead to look. It needs to be based on how far the missile is away from the target, but the target it also moving.

My missiles have a constant thrust, combined with a weak ability to turn. The hope is they will be fast and exciting, but steer like a cow (ie, badly, for the non HitchHiker fans out there).

Anyway, seemed like a kind of fun problem for Stack Overflow to help me solve, so any ideas, or suggestions on better or "more fun" missiles would all be gratefully received.

Next up will be AI for dodging them ...

解决方案

What you are suggesting is called "Command Guidance" but there is an easier, and better way.

The way that real missiles generally do it (Not all are alike) is using a system called Proportional Navigation. This means the missile "turns" in the same direction as the line-of-sight (LOS) between the missile and the target is turning, at a turn rate "proportional" to the LOS rate... This will do what you are asking for as when the LOS rate is zero, you are on collision course.

You can calculate the LOS rate by just comparing the slopes of the line between misile and target from one second to the next. If that slope is not changing, you are on collision course. if it is changing, calculate the change and turn the missile by a proportionate angular rate... you can use any metrics that represent missile and target position.

For example, if you use a proportionality constant of 2, and the LOS is moving to the right at 2 deg/sec, turn the missile to the right at 4 deg/sec. LOS to the left at 6 deg/sec, missile to the left at 12 deg/sec...

In 3-d problem is identical except the "Change in LOS Rate", (and resultant missile turn rate) is itself a vector, i.e., it has not only a magnitude, but a direction (Do I turn the missile left, right or up or down or 30 deg above horizontal to the right, etc??... Imagine, as a missile pilot, where you would "set the wings" to apply the lift...

Radar guided missiles, which "know" the rate of closure. adjust the proportionality constant based on closure (the higher the closure the faster the missile attempts to turn), so that the missile will turn more aggressively in high closure scenarios, (when the time of flight is lower), and less aggressively in low closure (tail chases) when it needs to conserve energy. Other missiles (like Sidewinders), which do not know the closure, use a constant pre-determined proportionality value). FWIW, Vietnam era AIM-9 sidewinders used a proportionality constant of 4.

这篇关于如何制造“拦截导弹"?玩游戏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆