#How to set up bunny hopping mechanic

1 messages · Page 1 of 1 (latest)

flint kelp
#

So, i watched a tutorial (this one : https://www.youtube.com/watch?v=v3zT3Z5apaM), for learninghow to make a bunny hopping mechanic for my fats fps game.
I pass some time trying to replicate his code in Godot, but it turned out to be unsuccessful.

Some i'm asking for help here, because i'm really struggling about how to set up this mechanic

For now, i have a movement script, with acceleration/decceleration/air control taken into account, as well as a function that get the wishDirection value every time a direction key is pressed :

func move(delta):
    var input_dir = Input.get_vector("left", "right", "frontward", "backward") 
    var direction = (cameraHolder.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
    
    calculateWishDirection(direction)
 
    if is_on_floor():
        if direction:
        velocity.x = lerp(velocity.x, direction.x * moveSpeed, moveAcceleration * delta)
        velocity.z = lerp(velocity.z, direction.z * moveSpeed, moveAcceleration * delta)
        else:
        velocity.x = lerp(velocity.x, direction.x * moveSpeed, moveDecceleration * delta)
        velocity.z = lerp(velocity.z, direction.z * moveSpeed, moveDecceleration * delta) 
    else:
        if direction:
        velocity.x = lerp(velocity.x, direction.x * moveSpeed, airControlForce * delta)
        velocity.z = lerp(velocity.z, direction.z * moveSpeed, airControlForce * delta)
        else:
        velocity.x = lerp(velocity.x, direction.x * moveSpeed, inAirMoveDecceleration * delta)
            velocity.z = lerp(velocity.z, direction.z * moveSpeed, inAirMoveDecceleration * delta) 
        
func calculateWishDirection(direction):
     wishDirection = direction 

Explanation of how the player movement code in Quake gives rise to these three different player movement "bugs", with a quick look at TAS movement mechanics at the end.

Big thanks to the Quake Speedrunning Discord for helping me out with getting TASQuake running on my machine, and for clarifying terminology.

Here are the original C versions of...

▶ Play video
tight cloud
#

Hi there, not sure about the article, but IIRC one of the factors involved in bunny hopping was "lazy" coding by not normalizing the movement vector.

(Y-axis obmitted for clarity)
For vec2(x-axis-velocity, z-axis-velocity)
So vec2(1, 1).length > vec2(1,0).length

If you rotated while mid-air away from your wish direction, so that your view angle towards wish direction is ±45 degrees you get a sqrt(2) instead of 1 multiplier on movement speed. The closer the view angle(direction) on touchdown to your wish direction, the smaller the gain

flint kelp
#

I think I'll put this mechanic aside for now, as I don't have the necessary skills to set it up properly.