Jumping feels linear instead of parabolic

prisoncube

New member
Jumping just feels extremely off no matter how I tweak the values, how can I achieve a natural feeling jump? I thought using the values from the sample scene character would work but even that feels incorrect. Honestly, I'd be satisfied with an answer that just tells me some magic parameter values to use, but I'm starting to feel like maybe its not a me problem.

This discord user explains it better:

Thanks
 

Attachments

  • Screenshot 2024-02-09 at 12.03.35 PM.png
    Screenshot 2024-02-09 at 12.03.35 PM.png
    147.1 KB · Views: 8
The jump relies on the gravity amount to bring the character back down. This value is accumulated within CharacterLocomotion.UpdateDesiredMovement. I can add it to my list to add another accumulation type, but you could also subclass and provide a different value:

Code:
            if (!m_Grounded && UsingGravity) {
                m_GravityAccumulation += m_GravityAmount * m_TimeScale * Time.timeScale * Time.deltaTime;
                m_DesiredMovement += m_GravityDirection * (m_GravityAccumulation * m_TimeScale * Time.timeScale);
            }
 
Anyone find a solution to this? I'm noticing this now too. The character seems to suddenly have a lot of downward velocity when he reaches the peak of the jump, when he goes from the jump to fall state. He accelerates a little downward, but not much, so that's why it feels linear. You can see this a lot if you turn the jump force up and the force damping down. The code you showed here seems like it would give a smooth feeling jump, so maybe there's code in the jump or fall that cause this? IDK.
 
You can output the velocity with:

Debug.Log(m_CharacterLocomotion.LocalVelocity.y);

When I just tried that I got:
1.199
0.09
-1
-2.2
So it moves about 1.1 units more each tick. I can see this being a bit much though so I'll adjust the default gravity values in the next update.
 
You can output the velocity with:

Debug.Log(m_CharacterLocomotion.LocalVelocity.y);

When I just tried that I got:

So it moves about 1.1 units more each tick. I can see this being a bit much though so I'll adjust the default gravity values in the next update.
Not sure I understand, what values are you gonna change? The numbers you got seem like they would lead to a smooth jump motion, so I’m not sure why it feels like he instantly has a lot of downward velocity right after the peak of his jump for me. I’ll look at it more when I get home today
 
I'm not sure what I was going to change, just look into tweaking the gravity a bit. It could also be animation related in that the animation looks like the character is moving down more than they actually are.
 
Just added this one line of code to your Jump ability and that made it a lot smoother. I think the problem came from the fact that your jump script was driving what his desiredMovement was while the CharacterLocomotion script was also doing the same thing. So once the jump ability turns off, the CharacterLocomotion has a bunch of accumulated gravity which makes the character suddenly have a lot of downward speed 1741143731701.png
 
Awesome! I'll take a look at making a similar change. Thanks for the suggestion!
 
I was just looking at this and instead of setting the accumulation every frame what do you think of just setting it within Jump.AbilityStopped:

Code:
        protected override void AbilityStopped(bool force)
        {
            base.AbilityStopped(force);

            m_Jumping = false;
            m_CharacterLocomotion.GravityAccumulation = 0; // NEW

This should still give the smooth results without setting it every frame.
 
Sorry, didn't see you sent this until now. I tried that and it's definitely smoother than before, but I think when you do this the character is accelerating downward more during the jump than after it ends because your jump script and characterlocomotion script are both adjusting the position due to gravity during the jump. Does that make sense? It's definitely a lot smoother this way than it was before, but I don't think it's as smooth as the solution I came up with. To avoid setting it every frame, maybe characterlocomotion could just stop accumulating gravity while the jump ability is active or something. Not sure how to do that though
 
@RogueSnake Hi, I haven't taken a closer look at your suggestions for smoother jumping, but for your question as to how preventing gravity accumulation while the Jump ability is active, the State System was created for this kind of task ! You could add a parameter like this to Character Locomotion :

C#:
        [SerializeField] protected bool m_UseGravityAccumulation = true;
        public bool UseGravityAccumulation { get => m_UseGravityAccumulation; set => m_UseGravityAccumulation = value; }

And then in CharacterLocomotion.UpdateDesiredMovement create an if statement that encompasses this existing line :

C#:
                if (m_UseGravityAccumulation)
                {
                    m_GravityAccumulation += m_GravityAmount * m_TimeScale * Time.timeScale * Time.deltaTime;
                }

Optionally add this line in CharacterLocomotionInspector where you see fit, maybe in the Physics section :

C#:
            FieldInspectorView.AddField(target, "m_UseGravityAccumulation", foldout);

And finally create a state preset for the Ultimate Character Locomotion component on your character prefab that sets UseGravityAccumulation to true when the Jump state is active (see the attached picture, can't have it displayed inside the post for some reason).

Let me know if this was helpful :)
 
Screenshot (2281).png

Forum is messed up again, so here's a separate post to share a picturing illustrating the Jump state.
 
Back
Top