Accumulated gravity force is preventing jump from happening

Unima9000

New member
Hello.
I'm making arcade shooter using UFPS2.
I want my character to be able to do a double jump. For that purpose i using parameter "Max Repeated Jump Count". Set it to 1.

But there is the problem occurs:

My character's jump force on ground is different than jump force while it being in air.
Seems like, the more character is being in air, the more it's being pushed by gravity towards the ground.

So, for example, if i jump with my character from super high platform and continues to fall for a long time, when i press "Jump" - char. wont jump, because accumulated gravity force if much bigger than jump force.

So, my question is:
How to reset accumulated gravity down to 0 at the moment when jump occurs?

Here is the gifs to illustrate the problem:

1) Jump on the ground

Jump occurs normally:


2) Jump in air, after long falling

I pressed jump right before ground several times, but it looks like i didn't at all, because accumulated gravity force is too strong:
 
There are three different types of forces that can be applied:

1. Initial Jump Force
2. Hold Jump Force
3. Repeated Jump Force

The Hold Jump Force is a small value that allows you to jump higher the longer that you hold. When these forces are applied they are additive in that your current velocity is taken into account. In a future update I can add an option so they are absolute, but right now you'll need to modify the jump ability in order to make this change.
 
When these forces are applied they are additive in that your current velocity is taken into account.
For now i using sort of "hack" to do what i need:
I'm turning off gravity every time when player jumps and then turn it on after 0.001 sec. Well, i continue to use that when. Thanks for aswer! I have 1 last question:
In which script can i find that gravity code?
 
There are three different types of forces that can be applied:

1. Initial Jump Force
2. Hold Jump Force
3. Repeated Jump Force

The Hold Jump Force is a small value that allows you to jump higher the longer that you hold. When these forces are applied they are additive in that your current velocity is taken into account. In a future update I can add an option so they are absolute, but right now you'll need to modify the jump ability in order to make this change.

For the sake of testing, I made `CharacterLocomotion.m_GravityAmount` public, and then in the Jump ability's `OnRepeatedJump` I call `m_CharacterLocomotion.m_GravityAmount = 0;` to clear the accumulated gravity. With these changes I get the effect I'm looking for (repeated jumps that ignore accumulated gravity). This results in an air jump, regardless of whether the character is descending or not, that matches the same force as the original jump from the ground.

@Justin These edits won't scale with UPC/TPC updates so do you have a recommendation or another approach using the proper APIs for achieving the same effect?
 
Gravity amount is a property so you don't need to make the field change. Then for the jump ability I would subclass it instead of modifying it directly.
 
@Justin Thank you for the notes. The aforementioned changes were temporary for testing purposes only. I did this to quickly check if I got the reset-accumulated-gravity behavior I was after. The answer was yes.

Regarding:

Gravity amount is a property so you don't need to make the field change. Then for the jump ability I would subclass it instead of modifying it directly.
  1. `GravityForce` is the property accessor for the `private m_GravityAmount` field but it is `protected` not `public`. Are you referring to another accessible property for achieving this reset-accumulated-gravity behavior?
  2. I agree, subclassing is the scaleable approach
 
Top