RMRK is retiring.
Server is paid up for the rest of 2026, but the forum may go after that. See here for more information. Please archive or save anything you would like to keep before 2027.
Main Menu
  • Welcome to The RPG Maker Resource Kit.

[GM] Making a enemy face you...

Started by Identity, September 07, 2007, 01:56:44 AM

0 Members and 1 Guest are viewing this topic.

Identity

I want to make it so that no matter where the enemy moves in the room, it'll always be facing in your general direction. How can I do this? :/

BTW I'm really tired as I write this so hopefully it makes sense. :D

iceflame1019

hmmmm...well, I know that it involves multiple sprites if it's not top-down, but if it's TD then all you need is the right sprite-rotation codes.  Unfortunately my advice ends there...as of yet I am not very fluent in this area of GML.

I know that there are some rotation tutorials on the GMC that involve rotating to face the mouse, you could adapt those from mouse to player object.

Want a personal sig like this? Ask Firerain:
http://rmrk.net/index.php/topic,20203.0.html

Arrow

Very easily.

I'm assuming a number of things here, so replace the names of the objects and sprites as needed:

The player is called player_obj
The enemy is called enemy_obj
The enemy has a sprite for left and right facing- they are called face_left and face_right

Now you would do something like this in the enemy's step event. If you have more than two sprites, it gets a bit more complex, but it's easy enough to change.


if self.x<player_obj.x{self.sprite_index=face_right}
if self.x>player_obj.x{self.sprite_index=face_left}


That help?

Lemme know if I messed up, that was off the top of my head. :P

Identity


Arrow