playMaker

Author Topic: 2d ai direction check - SOLVED  (Read 2253 times)

darrkbeast

  • Playmaker Newbie
  • *
  • Posts: 15
2d ai direction check - SOLVED
« on: November 11, 2013, 02:42:55 PM »
I cant seem to locate a action to help me with this. I may have over looked it, or searched wrong. What I want to do is change my sprite depending on which direction the NPC is going. I am working on the x/z only. Also the npc's work off a script, no physical input from me.

I really only need a action of set off them that first picks up on the npcs movement, and then sends a event based of their movement. Axis Raw Input would work perfect if there was a way to translate the npcs movement into a variable it could use.

Thanks for any help that is available.


UPDATE
(I found the vector compare action in the forum and it allowed me to get what I needed.)
« Last Edit: November 12, 2013, 08:37:08 PM by darrkbeast »

Mayhem

  • Full Member
  • ***
  • Posts: 171
Re: 2d ai direction check
« Reply #1 on: November 11, 2013, 03:38:38 PM »
Here is just an ideas what you could do:

- assuming your NPC moves left/right you could give him an int variable "i_Direction" and handle it like this:
 -> when NPC moves to left set it to -1
 -> when NPC moves to the right set it to 1
 -> when NPC doesn't move at all set it to 0
- with this variable you can determine which direction the NPC is facing
and do your other stuff

darrkbeast

  • Playmaker Newbie
  • *
  • Posts: 15
Re: 2d ai direction check
« Reply #2 on: November 11, 2013, 04:54:24 PM »
That makes since, but how do I get which direction the npc moves. I use A Star with playmaker plug in, so my npc locates target and heads there, but I don't see a way to store the directions the nps going. If I can do that, what you describe would work great. Oh he moves up, down, left and right on the x,z plans.

darrkbeast

  • Playmaker Newbie
  • *
  • Posts: 15
Re: 2d ai direction check
« Reply #3 on: November 12, 2013, 09:48:36 AM »
Ive been reading some forums and I think I will try to use Get Velocity action. I think that will get me the direction so I can store it and compare it, then I can use a the method you mentioned mayhem. As soon as I get home Ill try this, from looking into that action I think its what I need.