Skip to main content
OverflowAI is here! AI power for your Stack Overflow for Teams knowledge community. Learn more
48 votes
Accepted

How to differentiate landing on top of an object from falling down the side?

There are three common ways games sort this out: Minimum Separation Vector Upon a collision, compute the shortest movement that pushes the bodies apart into a non-intersecting position. If I've ...
DMGregory's user avatar
  • 135k
6 votes
Accepted

How to control jump strength by how long the player presses the jump button?

You have essentially 2 options. You can either apply a constantly decreasing force to the character while the player is pressing the space button and stop immediately when they release it or apply a ...
Bálint's user avatar
  • 14.9k
3 votes
Accepted

How to make an object jump an equal height whenever it hits the ground?

Are you getting different results per jump on the same item, or are you trying to replicate the same height on different objects? ForceMode.Impulse is dependent on the mass of the object you're using ...
Christopher H.'s user avatar
2 votes
Accepted

Dynamic force behind logical jumping on 3 axis'

So first, in the formula: velocity.x = x - ( x + ( 10 * math.cos ( ( rz + 90 ) * math.pi / 180 ) ) ); The two 'x's cancel out each other: ...
Stephane Hockenhull's user avatar
2 votes
Accepted

Logical math behind jumping in a 3D world

It's the same as you'd do it for 2D, just with an extra axis. Use the same exact equations you do for a 2D game, something similar to the equations of motion or the kinematics equations. For each ...
House's user avatar
  • 73.2k
2 votes
Accepted

Prevent player from jumping on a mesh

You could modify the existing collider on the mesh so that it is less "realistic" (aka less form-fitting) but better blocks the area in question. You could also just remove the collider altogether ...
GorkTi200's user avatar
  • 116
2 votes
Accepted

Creating proper jump mechanics in LibGDX with Box2D?

SMB "weakens" gravity to extend jump height when these three conditions are met: You are still moving upwards. You didn't release the jump button since you left the ground. You didn't collect a power ...
AturSams's user avatar
  • 10.5k
2 votes
Accepted

Play animation of the jump properly in Unity2D

Jump Animation in 2D Games There are three main state in any Jump state which can be understood with the help of this image . so for smooth jump animation- First thing we need to set the ...
Rakesh's user avatar
  • 539
2 votes

Play animation of the jump properly in Unity2D

It would be smarter to create a separate animation for the landing frame, and make sure your current animation is set to not loop when you click on it in the inspector. Use an animation controller to ...
Ariss's user avatar
  • 31
2 votes

Jump-through & drop-down platform

I'm pretty sure you can deal with this by ignoring the collision if the y-component of the velocity is positive (the player is moving upward). Alternately you might be able to use the collision ...
Unreal_Me's user avatar
  • 355
2 votes

Keep platformer jump height consistent with different frame rates

You need to decouple the render frequency from the simulation frequency: You measure the delayed time, do an appropriate amount of simulation steps, then render the frame. The easiest way to do this, ...
Bram's user avatar
  • 3,719
2 votes

Height in 2D game

So, the way jumping works in Zelda is kind of unintuitive at first, but if you think about it, it makes a lot of sense. In modern games, sprites and models ARE the game objects, so we've become used ...
basklein's user avatar
  • 416
2 votes

Player double jumps immediately with a single press when using new Input System

If control.StartRun == false and control.CanDoubleJump == true you are double-jumping right after jumping. ...
yees_7's user avatar
  • 21
1 vote

Touch input not working well for mobile game made with Unity 2D

Your main problem is that you're checking for input in FixedUpdate. FixedUpdate is not guaranteed to run every frame, or only ...
DMGregory's user avatar
  • 135k
1 vote

Double jump, without allowing two jumps after falling down a cliff

The trick here is to count air jumps separately from the initial ground jump. You always allow a jump from the ground, and you decrement your remaining air jumps only if you're not on the ground. So ...
DMGregory's user avatar
  • 135k
1 vote

Help with 3D Double Jumping in Unity

There are two problems here. First, as you surmised, GetButton() asks "is the button currently in the pressed state?" So unless the player manages to tap the ...
DMGregory's user avatar
  • 135k
1 vote

Parabolic Jump Libgdx Without Box2D and With Vectors

Here I created jump function which increases velocity toward upwards. Movement function, on the other hand, updates sprite(the player)'s position each frame. Trick is movement function uses velocity ...
Burak's user avatar
  • 11
1 vote

Unity2D Register which player colliders have activated

How about using a single rectangle only? Calculate the distance to the other colliding asset. The smaller component will tell you the axis, the sign of that component the direction. For example a ...
Mario's user avatar
  • 8,497
1 vote
Accepted

How can I change the sprite while jumping?

You don't want to draw a jumping character only when the player presses the jump key, rather whenever he's floating in mid-air: ...
liggiorgio's user avatar
  • 4,811
1 vote

Why does the player jump every time it touches the ground in my JavaScript game?

Update - Nov 28, 2016 One solution to your issue is to switch to mousedown and mouseup with the following event handler, as shared before: ...
BobGneu's user avatar
  • 222
1 vote
Accepted

How to jump in Box2D with LibGDX

you can do like this: In your hud class ...
Leonardo Lima's user avatar
1 vote
Accepted

Why does my Character Jump only Half as High?

F=MA. Or, Force = Mass * Acceleration. It appears you're dividing out the mass from your queued forces and impulses to deal with just acceleration, but you're not putting the mass back in when you ...
House's user avatar
  • 73.2k
1 vote
Accepted

Inconsistent jump height

The most commonly used method in commercial engines is the semi-implicit Euler method that I'm already using as you can see in my pseudo-code (https://gafferongames.com/post/integration_basics/). But ...
Martin's user avatar
  • 203
1 vote
Accepted

Jump Script Component For Character Controller

Couldn't find a solution that works like AddForce, but I solved this using a verticalVelocity variable that gets passed into a Vector3 jumpVector variable which calls Move on the characterController. ...
avereux's user avatar
  • 121
1 vote

Unity, how to detect landing after jump?

You can use a layer Mask and check against it. [SerializeField] private LayerMask groundLayer; bool onground = false; Set the ground you use to a ground layer ...
Justin Markwell's user avatar
1 vote

How do I make my character jump on a platform?

The function you are calling (jump) is only being defined AFTER the method that is handling the input, so it happens the error "jump is not a function". Just move ...
DH.'s user avatar
  • 551
1 vote

Creating proper jump mechanics in LibGDX with Box2D?

iforce2d to the rescue. if you can do some vector math nothing is impossible. https://www.iforce2d.net/b2dtut/jumping
Adolf's user avatar
  • 111
1 vote

Ball jumping algorithm

I have a suggestion. Design short segments of block configurations (maybe a sequence of 4 to 10 blocks). Make several configurations (maybe 30) and play with them in game until you are clear on ...
Neal Davis's user avatar
1 vote
Accepted

how to make my character jump

You need to implement Kinematics - Movement Obliquely in his game. Of course, if you want to simulate our world. Remind your world your rules. Or if you prefer to use a ready-made physical engine like ...
Bill Rock's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible