DIV ARENA FORUMS

Rotation towards an object, then advancing

Hikaru - 31-12-2016 at 01:05 AM

I'm working on a simple game that uses fget_angle to chase down a player in a scroll region (using advance(spd) to move). What I'm trying to accomplish is having the enemy rotate, so that it turns towards the player, so that the "pointy" part of the enemy is facing the player, and THEN moving the enemy towards the player. So far, with my experiments, I've got the enemy spinning as it moves towards the player. I've tried a number of different things but I can't quite get the correct result. Using just fget_angle "snaps" the enemy to the proper angle towards the player, and it looks somewhat hokey to me. Any advice on how to do this? Any help is greatly appreciated.

[Edited on 31-12-2016 by Hikaru]

MikeDX - 31-12-2016 at 09:43 AM

The function you need is near_angle. Check the help system and try the example program, it does exactly what you want it to do :)

Hikaru - 31-12-2016 at 11:19 PM

Darn! Don't know how I missed that one! Thanks for pointing it out. It looks quite straightforward.

EDIT: aaaaaand it works! Thanks Mike :)

[Edited on 31-12-2016 by Hikaru]