playMaker

Author Topic: [SOLVED] Odd behaviour with Get Axis Vector. Anybody else experiencing?  (Read 2190 times)

JonathanBurroughs

  • Junior Playmaker
  • **
  • Posts: 73
  • Some kind of independent game developer
    • @HiFiHair
Hey all,

Does anybody else find that if they use Get Axis Vector to drive their character movement, that when both Horizontal and Vertical inputs are used (say to move diagonally) that the two are combined, so you end up with diagonal movement being twice as fast as either component independently?

Is there a known solution to combating this?
« Last Edit: April 02, 2014, 08:07:43 AM by HiFiHair »

JonathanBurroughs

  • Junior Playmaker
  • **
  • Posts: 73
  • Some kind of independent game developer
    • @HiFiHair
Re: Odd behaviour with Get Axis Vector. Anybody else experiencing?
« Reply #1 on: April 02, 2014, 05:24:49 AM »
Strangely this isn't the case when I use the Xbox Controller as input, only with keyboard input. I shall investigate further.

Derphouse

  • Playmaker Newbie
  • *
  • Posts: 17
Re: Odd behaviour with Get Axis Vector. Anybody else experiencing?
« Reply #2 on: April 02, 2014, 05:49:39 AM »
As far as I can tell from the translate, you move in a square, and not in a circle, so yes, reaching the "corners" of the square will take the same amount of time as to any given side.
I'm not sure about the xbox controller.. maybe the analog handles movement with an equal radius of 1 as it's calculating more values to move from 0 to 1 than the keyboard.

Don't know if this was any help, just giving my 2 cents :)

JonathanBurroughs

  • Junior Playmaker
  • **
  • Posts: 73
  • Some kind of independent game developer
    • @HiFiHair
Re: Odd behaviour with Get Axis Vector. Anybody else experiencing?
« Reply #3 on: April 02, 2014, 06:05:19 AM »
Ah, sorry. I maybe confused the matter in my original post.

Here's an explanation by example.

If I hold the "D" key to move horizontally right I cross 10 Unity units in 10 seconds. If I hold the "D" and "W" keys, to move diagonally left and forward, I cross the same horizontal distance in half the time; 20 units in 10 seconds.

It's as if the forward component is being added to the horizontal somehow.

The same is the case in the other axis too. If I move forward and then add a horizontal component, my forward movement rate is doubled.
« Last Edit: April 02, 2014, 06:29:44 AM by HiFiHair »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Odd behaviour with Get Axis Vector. Anybody else experiencing?
« Reply #4 on: April 02, 2014, 07:19:26 AM »
Hi,

 yes, it's the "expected" behavior, what you need to do is clamp the vector so that its magnitude it never greater than 1 and then diagonal movement will operate at the same speed.

bye,

 Jean

JonathanBurroughs

  • Junior Playmaker
  • **
  • Posts: 73
  • Some kind of independent game developer
    • @HiFiHair
Re: Odd behaviour with Get Axis Vector. Anybody else experiencing?
« Reply #5 on: April 02, 2014, 08:07:21 AM »
That did the trick!

Stuck a Vector3 Clamp Magnitude in the player movement FSM. All is well.

Thank you so much, jeanfabre.