Use this tutorial to learn how to have enemies, opponents, or NPCs look at the player in a top-down game.
Tommy Leung from Ourcade writes: "Are you making a top-down game where enemies or opponents should track or keep their eye on the player?
Maybe you have a turret that should face a moving target before firing?
You know that you need to rotate the turret but how do you know what that angle should be?
If you remember your trigonometry classes then you can probably figure it out but Phaser can do the math work for us!
In this article, we will show you how to get that angle using the player's position and the position of the enemy that should face the player."
Learn to code and lead your intrepid crew on a mission to save The Cloud in TwilioQuest, a PC role-playing game inspired by classics of the 16-bit era. Free forever, and available now for Windows, Mac, and Linux.
The first book on the creation of HTML5 cross platform games using Phaser 3 and other free software.
- By Emanuele Feronato
- 155 Pages
- 28 Source Code Examples
- Build a complete game from start to finish
- Cross Platform
- Scaling for devices