#I can't jump while holding a diagonal input?

1 messages · Page 1 of 1 (latest)

marsh fiber
#

I can move diagonally just fine but when I jump while holding that direction I can't. I can jump holding any other direction just fine though.

CODE:

    printt(velocity.x, velocity. y, velocity.z)
    
    # Add the gravity.
    if not is_on_floor():
        if velocity.y >= 0:
            velocity.y -= gravity * delta

    # Handle Jump.
    if Input.is_action_just_pressed("jump") and is_on_floor():
        velocity.y = sqrt(jump_height * 2.0 * gravity)

    # Get the input direction and handle the movement/deceleration.
    # As good practice, you should replace UI actions with custom gameplay actions.
    var input_dir := Input.get_vector("move_left", "move_right", "move_forward", "move_back")
    var direction := (transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
    
    if Input.is_action_just_pressed("dash"):
        if is_dashing != true:
            is_dashing = true
        else:
            is_dashing = false

#region BaseMovment
    if is_dashing == false:
        print("Slow...")
        if direction:
            velocity.x = move_toward(velocity.x, direction.x * base_speed, base_ground_accel)
            velocity.z = move_toward(velocity.z, direction.z * base_speed, base_ground_accel)
        else:
            velocity.x = move_toward(velocity.x, 0, base_ground_accel)
            velocity.z = move_toward(velocity.z, 0, base_ground_accel)
#endregion```

**UPDATE:**
It appears to happen refuse to jump when using the arrow keys but WASD is fine now? I don't know what changed.
balmy ember
#

there is a thing with keyboards and godot ( its not only godot specific i think but i experience it only there ) that doesnt recognize multiple arrow keys and space, for example, simultaneously

#

i've seen it come up a few times for people, dont know if its hardware specific and also forgot if there is a workaround that still allows for arrow keys or if you have to move to WASD

gentle thistle
#

This is known as keyboard ghosting and it's hardware dependent. It's mentioned (somewhat hidden in plain sight) in the documentation ( https://docs.godotengine.org/en/stable/tutorials/inputs/input_examples.html#keyboard-events ) , which in turn references a good explanation on stackexchange.

https://gamedev.stackexchange.com/a/109002

Nothing you can do, but change the input layout or buy a "better" (gaming oriented) keyboard.

marsh fiber
#

Ok. Thank you both for your time!

gentle thistle
#

You are welcome! Have fun! 😊

iron sand
#

Certain regions of keyboards can only accept certain numbers of simultaneous inputs

#

This is a hardware limitation of your keyboard. Unfortunately, the only solution is that you must purchase a better keyboard that does not have this limitation.

To be more specific:

In order to save money, keyboard manufacturers often put many keys on the same "circuit" of sorts within the wiring of the keyboard. This prevents multiple keys in the same region of the keyboard from being pressed simultaneously. Sometimes it even prevents more than 2 keys at all from across the whole keyboard being pressed at once. Often the shift, ctrl, and alt keys are not within this limitation, so you can hold shift and press 2 other keys at once and it will still work fine.

Even high-end gaming keyboards often have a similar hardware limitation, although the cap is much higher so that it is unlikely to be reached during the normal course of gaming.