How to create an “intercept missile” for a game?

后端 未结 5 789
眼角桃花
眼角桃花 2021-01-31 11:50

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 missil

5条回答
  •  借酒劲吻你
    2021-01-31 12:27

    Have you considered negative feedback on the recent change of bearing over change of time?

    Details left as an exercise.

    The suggestions is completely serious: if the target does not maneuver this should obtain a near optimal intercept. And it should converge even if the target is actively dodging.

    Need more detail?

    Solving in a two dimensional space for ease of notation. Take \vec{m} to be the location of the missile and vector \vec{t} To be the location of the target. The current heading in the direction of motion over last time unit: \vec{h} = \bar{\vec{m}_i - \vec{m}_i-1}}. Let r be the normlized vector between the missile and the target: \vec{r} = \bar{\vec{t} - \vec{m}}. The bearing is b = \vec{r} \dot \vec{h} Compute the bearing at each time tick, and the change thereof, and change heading to minimize that quantity.

    The math is harrier in 3d because of the need to find the plane of action at each step, but the process is the same.

提交回复
热议问题