Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Character face enemy when enemy collusion?

What i want to happen is a player is lets say running away from a enemy. The enemy is a lot faster and catches him. What i want is so the player faces where the enemy caught him at. The enemy could come any way, left, right, down so I want the player to face left if the enemy touches him on his left, the player to face right where the enemy is if the enemy touches him from the right etc. If this is possible, please tell me how i can do it. I've tried to explain it the best I can.

Thank you if you can help.
 
Well, have 4 variables. On event touch, have VPlayerX = Player's Map X, VPlayerY = Player's Map Y, VEventX = This events's Map X, VEventY = This events's Map Y. You can call those variables anything, of course. Then, have four conditionals. You can check out "Set handling when conditions do not apply" since only one of those conditionals can apply anyway :

Condition : VplayerX > VeventX
@>Set move route : Player (Turn right)
Branch and
Condition : VplayerX < VeventX
@>Set move route : Player (Turn left)
Branch and
Condition : VplayerY > VeventY
@>Set move route : Player (Turn up)
Branch and
Condition : VplayerY < VeventY
@>Set move route : Player (Turn down)
Branch and

And after those conditionals you can do whatever you wanted (battle, etc).
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top