playMaker

Author Topic: [SOLVED] Help, playmaker 2D AI. Move Towards/Get Position/what??  (Read 4685 times)

keitaro3660

  • Playmaker Newbie
  • *
  • Posts: 16
[SOLVED] Help, playmaker 2D AI. Move Towards/Get Position/what??
« on: December 18, 2014, 12:24:58 AM »
hellooo
i currently get really stuck with the 2D AI movement..

how can the AI know if the player is behind him? and he must "FLIP" the sprite before "Move Toward" the player. not walking backward...

Look At 2D is not the solution, because it's rotate, not flip...

while Get Distance value is always give positive value, so the AI "SPRITE" won't know if the player is in front of him or behind him.
how should he know WHEN he must face/flip backward or not??

i want to make the enemy following player with the right FLIP.
i know it's something to do with the X scale. i just don't know what i must use to achieve this.

i really don't know what should i use, have been stuck for a while with this.
please help me, please step by step for what action should i use
« Last Edit: December 18, 2014, 01:27:10 AM by keitaro3660 »

escpodgames

  • Hero Member
  • *****
  • Posts: 687
    • Assets
Re: Help, playmaker 2D AI. Move Towards/Get Position/what??
« Reply #1 on: December 18, 2014, 12:27:34 AM »
You could...

Get the enemies Xposition
Get the players Xposition
Subtract the enemies Xposition from the players Xposition
Compare the results, greater than 0 would set the Xscale to 1 and less than to -1.
« Last Edit: December 18, 2014, 12:39:02 AM by LampRabbit »

keitaro3660

  • Playmaker Newbie
  • *
  • Posts: 16
Re: Help, playmaker 2D AI. Move Towards/Get Position/what??
« Reply #2 on: December 18, 2014, 12:53:43 AM »
You could...

Get the enemies Xposition
Get the players Xposition
Subtract the enemies Xposition from the players Xposition
Compare the results, greater than 0 would set the Xscale to 1 and less than to -1.
wow okay cool, thanks for reply :D i'll try it now

escpodgames

  • Hero Member
  • *****
  • Posts: 687
    • Assets
Re: Help, playmaker 2D AI. Move Towards/Get Position/what??
« Reply #3 on: December 18, 2014, 01:18:52 AM »
Let me know if it works ... in my head it does :P

keitaro3660

  • Playmaker Newbie
  • *
  • Posts: 16
Re: Help, playmaker 2D AI. Move Towards/Get Position/what??
« Reply #4 on: December 18, 2014, 01:26:26 AM »
Let me know if it works ... in my head it does :P
looolll, silly meee XD
the first time i tried your solution, i thought the Get Position space is set to Self.
It's working, but a bit weird because sometimes the value is always stay positive if the player is near.

i strugle for 30 minutes, then i try to change the Self to World, and....
VOILA!!!!
lol, silly me...
really thanks so much for your help!!!

this move towards feature really usefull for many things now XD
thank youuu thank youuu!!