Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: JonathanBurroughs on April 02, 2014, 05:03:43 AM

Title: [SOLVED] Odd behaviour with Get Axis Vector. Anybody else experiencing?
Post by: JonathanBurroughs on April 02, 2014, 05:03:43 AM
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?
Title: Re: Odd behaviour with Get Axis Vector. Anybody else experiencing?
Post by: JonathanBurroughs 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.
Title: Re: Odd behaviour with Get Axis Vector. Anybody else experiencing?
Post by: Derphouse 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 :)
Title: Re: Odd behaviour with Get Axis Vector. Anybody else experiencing?
Post by: JonathanBurroughs 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.
Title: Re: Odd behaviour with Get Axis Vector. Anybody else experiencing?
Post by: jeanfabre 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
Title: Re: Odd behaviour with Get Axis Vector. Anybody else experiencing?
Post by: JonathanBurroughs 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.