Character falling after jump with fall ability disabled

arenoo

Member
I modified the jump script to behave like a jetpack and I want to be in control of when the character should start falling. I came across this problem where even when I remove the fall ability the character still falls down after the jump. I tried looking into jump ability code but couldn't find anything related to falling.
 
I created a similar idea recently that works well. Not sure if this may help:
I did'nt make any change to existing jump ability or fall though. I created a new jetpack ability. I have a bool set to false for Isjumping until the jump button is actually pressed. If the button is not pressed character falls. I set an up and forward force to be applied to the player locomotion controller when the jump button is pressed.
If you wanted to stay in the air for longer and control when you fall, you could disable gravity with get button down then re-enable with get button up statement event. You could create a large trigger zone collider placed in the sky area, in addtion, that appears & cancels the ability after a certain length of time which is how I have arranged.
 
Last edited:
The fall ability just controls the animation, it doesn't apply any gravity forces. You should use the state system to adjust the gravity amount if you don't want those forces to be applied.
 
Okay, so I my problem is when I hold down the space bar I fly up using jetpack, then I release the button and the character starts falling down, then mid-air I press the jump button again and the character should start going up again but because of the "accumulated gravity velocity" it doesn't go up as much. I expect the gravity force to be cancelled out when I press jump button then start reacummulating when I release it. I am using the Force Hold in Jump ability to mimic a jetpack and I modified it to work repeatedly mid-air. My question is how do I reset the velocity accumulated by gravity? It seems like the controller starts adding downwards velocity as soon as I fly off the ground and ignores the velocity generated by jetpack. Here you can see what I want to achieve at 0:27
 
I created a similar idea recently that works well. Not sure if this may help:
I did'nt make any change to existing jump ability or fall though. I created a new jetpack ability. I have a bool set to false for Isjumping until the jump button is actually pressed. If the button is not pressed character falls. I set an up and forward force to be applied to the player locomotion controller when the jump button is pressed.
If you wanted to stay in the air for longer and control when you fall, you could disable gravity with get button down then re-enable with get button up statement event. You could create a large trigger zone collider placed in the sky area, in addtion, that appears & cancels the ability after a certain length of time which is how I have arranged.
I reduce gravity when the character is in air but the problem is the gravity acceleration doesn't stop when I start flying up mid-air. Its continuing to accelerate me downwards even though the jetpack thrust should have stopped it. Think of it this way. When I jump off a cliff I start accelerating towards the ground as expected. Lets say my velocity.y is 0 -> -5 -> -20 -> -35 throughout the time until I hit the ground. When I jump off the same cliff again and start the jetpack halfway it should start cancelling out the gravity. It indeed does cancel the gravity but when I turn off the jetpack I expect my velocity to start rising like the first example (0 -> -5 -> -20 -> -35) but instead it is rising much faster like 0 -> -20 -> -70 -> -200 ...
 
Yes your right, I get what you mean now. I have a similar issue but compromised and left it as it was as if it part of my game logic.
I'm finding around 10 seconds the player falls, with the jump button still pressed. Be great to figure a way to cancel accumulated gravity. The only thing that is re-setting this is when the player is on the ground. I may be wrong here but If I could somehow apply GetButtonUp logic over this Isgroundedlogic to (set true or false) in air I think it would resolve. Also I have been trying other different methods to stop accumulation but cant seem to prevent this. It sounds like your gravity is not returning back to your default value so rising faster. I also had the gravity issue not resetting so I have now not even adjusted gravity and relied on just forces so there is no change in gravity with the jet pack its just getting a boost with force applied for 10 seconds.

**Justin, Looks like when the player is grounded the accumulation of gravity re-sets. Is there a way to apply this same method for a gravity re-set to happen in mid air (when equipped with a Jetpack) just like it does when grounded?
Using the state system is something I need to improve on & grasp better. If possible would you be able to detail using the state system to achieve changing gravity amounts for a Jetpack scenario type set up?**
 
Last edited:
Instead of modifying the jump ability you should instead create a new flying ability. In the settings this ability should disable gravity and you can set the CharacterLocomotion's Gravity Accumulation to 0. If you have the Swimming Pack take a look at the Swim ability as swimming is essentially the same thing as flying.

There has been a lot of talk about flying though so I do think that I'll include it in the next feature update. I don't have an ETA on when we will be releasing the next feature update - we need to get through the Omni Animation launch first.
 
Thanks, this worked for me; Seeing as gravity is accumulating I never use gravity during Jetpack equipped /active, instead apply a new downforce with gravity set 0 method for when the button is not pressed. When the button is pressed force applied & gravity is set 0. GetButtonUp method was not working for me but this worked;
Code:
 if(!Input.GetButtonDown(Jump"); //button not pressed
Yes would be great to have a solid solution & for prehaps a range of flying methods if possible on a future update.
 
Last edited:
Top