top down leg animation matching direction your moveing and looking.

If I wanted a top down view and use mouse to turn character how would I make it so that whatever the opposite direction the player is moving in comparison to the way he walks his feet move that direction for eample.

I am aiming top left and I move torwards the bottom right and plays a animation going that direction. Then a second later I look bottom right and move to bottom right and instead I walk forward at it instead of backwards ? I hope understand >.<

You want the player to always face the cursor?

yea I have that down but you notice the feet when you push to move in a fps its easy to make the forward and backward animation for them the direction you need but with a players always looking at curser from top view and you going one direction the feet wont match up with the direction your moving pushing backward would play backwards animation but if you looking down that would look like your moonwalking lol any clearer ?

I think I understand - you want to essentially play a backwards - moving animation if he’s heading away from the cursor (while facing it), and you want him to play a forward-moving animation if he’s heading towards the cursor.

Ok, so, here it is. Use a Action armature with it set to property. There’s two ways to do animation for this -

  1. Use two Animation actuators - one for the forwards-moving animation, and one for the backwards-moving animation (the forwards moving one, but reversed - I think there’s a “Play Backwards” option).

  2. Alternatively, use one Action armature with a single animation (the forwards-moving one), and use Property to move it. Assign the property for the action actuator to work on to a variable (whatever, it doesn’t matter the name), then access the variable (obj[‘frame’]) and increase it if he’s moving towards the cursor, and decrease it if he’s moving away. Remember to put limits on the frame maximum and minimum of the animation yourself.

You’ll have to do math to determine how - use math.atan2(cursorpos.y - playerpos.y, cursorpos.x - playerpos.x) to find the angle from the cursor to the player (in radians), and then find (playermovey, playermovex) to find the angle that the player is moving on, with the playermovex and y being the variables that you move the player on. If the movement angle of the player minus the angle to the cursor is greater than the absolute value of Pi or so, then treat it as moving backwards. Otherwise, the player is moving forwards. That’s the best I can do without getting a blend file together.

oh my >.< I am going to prob wait do this then since it takes more complex code XD I am learning it though Ill try this though

Hmm… Okay, it basically breaks down to: if the absolute value of the ( angle of movement - angle of player to cursor ) > math.pi, then play the backwards animation. Otherwise, play the forwards one, I think.