playMaker

Author Topic: how to detect when gameobject is moving backwards/sideways?  (Read 1720 times)

Arfoster

  • Playmaker Newbie
  • *
  • Posts: 3
how to detect when gameobject is moving backwards/sideways?
« on: February 13, 2016, 10:15:06 AM »
Hello to all,

I have a character which can move and shoot in any direction and I am seeking advice on how to play the characters walking animation backwards when moving in the opposite direction to the way their facing...

I would also like to capture sideways as well but one problem at a time!

As always many thanks in advance for any help provided.

Regards,

Arfoster

Vallar

  • Junior Playmaker
  • **
  • Posts: 90
Re: how to detect when gameobject is moving backwards/sideways?
« Reply #1 on: February 13, 2016, 10:20:57 AM »
Hey,

I think what you can do is setup a variable let's say walkDirection and according to its value play a certain animation.

For example you can setup a float and when it is 1; you play walk forward. 2 would mean backward and sideways might be 3 and 4.

There might be another way but that is how I figured it out so far.

Hope that helps.

Arfoster

  • Playmaker Newbie
  • *
  • Posts: 3
Re: how to detect when gameobject is moving backwards/sideways?
« Reply #2 on: February 13, 2016, 02:31:33 PM »
Thanks for your reply

But with my character rotating constantly how does that work?

I'm guessing I would have to abandon the character simple move altogether and introduce a whole new movement process?

Sounds complicated but I'll try it....

Vallar

  • Junior Playmaker
  • **
  • Posts: 90
Re: how to detect when gameobject is moving backwards/sideways?
« Reply #3 on: February 13, 2016, 10:52:52 PM »
Hmm... I see what do you mean now. I think I missed that completely. Perhaps set an int variable and store the angle of your character. Then do a compare int where if the angle is more than X and less than Y it would move forward for example and then if it is between Z and M it would move backward?