Realistic Jumping
Posted
by
Seth Taddiken
on Game Development
See other posts from Game Development
or by Seth Taddiken
Published on 2012-10-30T04:47:05Z
Indexed on
2012/10/30
5:22 UTC
Read the original article
Hit count: 236
I want to make the jumping that my character does more realistic. This is what I've tried so far but it doesn't seem very realistic when the player jumps. I want it to jump up at a certain speed then slow down as it gets to the top then eventually stopping (for about one frame) and then slowly going back down but going faster and faster as it goes back down. I've been trying to make the speed at which the player jumps up slow down by one each frame then become negative and go down faster... but it doesn't work very well
public bool isPlayerDown = true;
public bool maxJumpLimit = false;
public bool gravityReality = false;
public bool leftWall = false;
public bool rightWall = false;
public float x = 76f;
public float y = 405f;
if (Keyboard.GetState().IsKeyDown(up) && this.isPlayerDown == true && this.y <= 405f)
{
this.isPlayerDown = false;
}
if (this.isPlayerDown == false && this.maxJumpLimit == false)
{
this.y = this.y - 6;
}
if (this.y <= 200)
{
this.maxJumpLimit = true;
}
if (this.isPlayerDown == true)
{
this.y = 405f;
this.isPlayerDown = true;
this.maxJumpLimit = false;
}
if (this.gravityReality == true)
{
this.y = this.y + 2f;
this.gravityReality = false;
}
if (this.maxJumpLimit == true)
{
this.y = this.y + 2f;
this.gravityReality = true;
}
if (this.y > 405f)
{
this.isPlayerDown = true;
}
© Game Development or respective owner