How to make a homing missile?

Hi, I’m newbie to Phaser3. I want to make some game(Like Space Shooter thing) but I want to add Homing Missile in my game that tracking player movement. Please give me some advice or tutorial so I can follow and learn by myself :slight_smile:. Thank you so much (Sorry for my bad English…)

1 Like

Game Mechanics Explorer has an example of a homing missile. It uses Phaser 2, but you’ll only need the logic, not the parts which interact with the framework.

The changes between Phaser 2 and 3 you should keep in mind are that this.game.add is just this.add, this.game.input is just this.input, this.game.math.angleBetween is Phaser.Math.Angle.Between, and this.game.math.degToRad is no longer a function, but a constant (Phaser.Math.DEG_TO_RAD) that you should multiply by.

thank you so much, i will reply later if i have a problem :slight_smile:

This is similar to “Basic Missile”:

Your missile object has an attribute called target storing a reference to the object you are shooting at. Additionally it has a function called moveMissle(). Every update of the game loop you determine the vector between your missile and the missiles target and move it along that vector . Now how much you move depends a bit on your implementation of your update loop.