Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7735137
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T07:25:32+00:00 2026-06-01T07:25:32+00:00

I’m trying to make jumping functionality in my Movement test. My character jumps and

  • 0

I’m trying to make jumping functionality in my Movement test. My character jumps and comes back down, but it’s very choppy and not smooth at all.
What happens is he juts up to his max height, then comes down smoothly.

I can spot the problem, the for loop doesn’t want to play nicely with the code. However, I don’t know how to circumvent this. Is there any way to keep the button press and have him jump up nicely?

Code:

if (leftStick.Y > 0.2f && sprite.Position.Y == position.Y || isPressed(Keys.Up) == true && sprite.Position.Y == position.Y) 
            {
                if (wasLeft == true)
                {
                    sprite.CurrentAnimation = "JumpLeft";

                }
                else if (wasLeft == false)
                {
                    sprite.CurrentAnimation = "JumpRight";
                }

                //This for loop is my issue, it works but it's jumpy and not smooth.

                for (movement.PlayerHeight = 0; movement.PlayerHeight < movement.PlayerMaxHeight; movement.PlayerJump())
                {

                    sprite.Position.Y -= movement.PlayerJump();
                }
            }
            sprite.StartAnimation();
        }
        else
        {

            leftStick = NoInput(leftStick);
        }

private Vector2 NoInput(Vector2 leftstick)
{
if (sprite.Position.Y < position.Y) //(movement.PlayerSpeed > 0) 
            {
                sprite.Position.Y += movement.PlayerHeight;
                movement.PlayerHeight -= movement.Player_Gravity;

                //sprite.Position.Y += movement.PlayerSpeed;
                //movement.PlayerSpeed -= movement.Player_Decel;
            }
            else
            {
                sprite.Position.Y = position.Y;
            }
}

Movement class:

public float PlayerMaxHeight = 15f;
public float PlayerHeight = 0;
public float Player_Gravity = 0.01f;
private const float Player_Jump = 0.35f;


public float PlayerJump()
{
    PlayerHeight += Player_Jump + Player_Gravity;
    if (PlayerHeight > PlayerMaxHeight)
    {
        PlayerHeight = PlayerMaxHeight;
    }
    return PlayerHeight;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T07:25:34+00:00Added an answer on June 1, 2026 at 7:25 am

    My general approach to get a jump really quickly is to use a bleed off value to make slightly smoother looking movement. I can’t look at any code/xna right now but my first thought would be something like below.

    Define variables:

    float bleedOff = 1.0f;
    bool jumping = false;
    

    Input update:

    if(input.JumpKey())
    {
        jumping = true;
    }
    

    Jumping update:

    if(jumping)
    {
        //Modify our y value based on a bleedoff
        //Eventually this value will be minus so we will start falling.
        position.Y += bleedOff;
        bleedOff -= 0.03f;
    
        //We should probably stop falling at some point, preferably when we reach the ground.
        if(position.Y <= ground.Y)
        {
            jumping = false;
        }
    }
    
    bleedOff = MathHelper.Clamp(bleedOff, -1f, 1f);
    

    Obviously the bleedOff value should be calculated with a bit more randomness, probably using a gravity value, to it to make it look right but this will give the illusion of acceleration/decceleration with the jump as they rise and fall.

    Rising very fast to begin with and slowing down and eventually starting to fall again and that will speed up. The clamp at the bottom will be your maximum vertical velocities.

    I just wrote this off the top of my head at work so apologies if it’s not quite what your looking for but I tried to keep it a bit more general. Hope it helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I have this code to decode numeric html entities to the UTF8 equivalent character.
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have a French site that I want to parse, but am running into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.