[SOLVED] Why is vertical jump distance affected by adding a horizontal force?

koan

  • Posts: 5
Hi,
I'm writing a custom jump behaviour that should allow the player to click where they want to jump, but I'm running into problems with forces.
With the attached behaviour, when I click directly above the player character the jump height is what I expect (just above the cursor). However, if I click to the left or right the jump height decreases depending on how far away in the x direction the mouse is (so if I click at the same height on the other side of the screen the player will gain hardly any height).

Why does this happen, and what can I change to make sure the height of the jump is only dependent on the y coordinate of the mouse?

(Or if there's an easier way I'm overlooking please enlighten me :) )

« Last Edit: June 13, 2012, 01:01:43 am by koan »

Hectate

  • *
  • Posts: 4643
The first thing I saw was that using "Negate" for your X Distance as force is probably wrong - you're already telling it to apply that force in the direction of 180 degrees...

The other thing that comes to mind is friction. Basically, if you jump straight up the player moves away from the surface immediately and goes upward. If you jump at an angle - particularly a very horizontal one - the player's bottom edge can "drag" along the surface for a little bit. That friction could reduce any force that you've applied.

That's just a guess though...
:
:
Patience is a Virtue,
But Haste is my Life.
Proud member of the League of Idiotic Stencylers; doing things in Stencyl that probably shouldn't be done.

koan

  • Posts: 5
The reason I'm negating x is that it seems like you can't apply a negative force - if the mouse is behind the player and I try to apply the distance (which is negative) as a force the player just goes straight up ... not sure if that's correct or a bug in my version.

Hmm, setting friction to 0 doesn't seem to make any difference apart from obviously infinite sliding.

Thanks for the reply though, it was worth a try!

froz

  • Posts: 250
I'm not sure why it doesn't work, but instead using force you can try setting x and y speed. The difference is that force take into account actor's previous movement (so if actor was falling down, applying force to top would only slow him down, while setting y-speed to positive would send actor up).

koan

  • Posts: 5
Argh, I feel stupid ... turns out I had the Jump and Run behaviour on the same actor which was capping the speed, disabling that makes it work perfectly. Thanks for the tip about speed though froz, didn't notice that action and as you say, it works better for what I want.

Sorry guys, my mistake >_<