Legacy GM How would I go about programming a flying enemy?

Hello again! I wanted to programme a flying enemy that waits until the player is close enough to it, then it'd swoop down from where it's idle towards the player's general area. How would I achieve such a thing? I currently haven't got a clear picture of how to do it.
 
If everything else in your game has gravity, simply not using gravity for your flying object will make it appear as though it's hovering. Then there are a couple of ways to make the flying physics look good. You could use angle_difference(ang1, ang2) to make the object slowly turn towards its target while maintaining a constant flying speed. Or you could use a combination of friction = speed/4, and motion_add(point_direction(x,y, player.x,player.y, 4), to give it that effect drifting through the air. Or if you have a flapping animation for your flying object, maybe add back in some gravity, and give it lift based on the current image_index.

Have this activated when point_distance(x,y,player.x,player.y) < given_number. And Perhaps have it return to perch after attacking. Or maybe let it attack a couple of times, each time having it flying a distance away.
 
Top