playMaker

Author Topic: Make a Character lean towards direction?  (Read 1615 times)

Prototype_6492

  • Junior Playmaker
  • **
  • Posts: 50
Make a Character lean towards direction?
« on: June 14, 2018, 11:44:12 AM »
Hey,

I was wondering how could we track the direction the player is going in? Mainly to use for leaning left/ right when the joystick is pressed any of those directions.

Thanks!

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: Make a Character lean towards direction?
« Reply #1 on: June 15, 2018, 06:34:17 AM »
hi.
You can use get axis or get axis event to track the direction :)

Prototype_6492

  • Junior Playmaker
  • **
  • Posts: 50
Re: Make a Character lean towards direction?
« Reply #2 on: June 15, 2018, 01:17:09 PM »
I tried, so for example if they pressed horizontal axis to the right, it would be +1, so i would store it in a float, and on the blend tree i would set +1 = lean right... thats if they were walking forward, but now if they walk towards us, and press horizontal to the right, it plays their lean right animation, rather then left. Since they now are walking towards us it should play a lean left animation.

idk if that makes sense.

verybinary

  • Junior Playmaker
  • **
  • Posts: 81
    • The Museum of Digital
Re: Make a Character lean towards direction?
« Reply #3 on: June 15, 2018, 01:45:12 PM »
first, pushing horizontal to the right will give a value from 0 to 1, and to the left, 0 to -1. you can round these numbers to work with solid variables, but axis values are .99999999 or .00000453 or something similar most of the time.

What I would do is check every frame to see if horizontal is more than .25 or .33(find a dead zone that works with your game) and if true, do your lean thing. not sure if youre playing with animation or raw, but do it then. if it falls below your dead zone, undo the lean.

if you wanna see what I mean about the .12345678, set up a gui text that displays the horizontal axis vale every frame(store the value into a float every frame, convert the float to string every frame, and update the gui with new string every frame I keep a "debugtext"(that's what I call it, not playmaker terms) around because they are useful for everything)

Prototype_6492

  • Junior Playmaker
  • **
  • Posts: 50
Re: Make a Character lean towards direction?
« Reply #4 on: June 15, 2018, 01:56:31 PM »
I got that part down. I simply store the axis in a float, and set the animators X_Axis and Y_Axis values to the ones I get from the axis themselves. That's not the issue I'm having.

On the Blendtree between my run straight, lean left, and lean right actions. The parameters are set so that if Y_Axis is Positive and X_Axis is positive, it would lean right.

But lets say the player is running towards the screen. If Y_Axis is negative, but the X_Axis is positive, the character himself will be turning to his left (Our right), but still playing the Lean right animation, because the X is positive right.

but I think I may have figured something out.