minetest / minetest

Minetest is an open source voxel game-creation platform with easy modding and game creation
https://www.minetest.net/
Other
10.56k stars 1.99k forks source link

Improving Auto Jump behavior #14612

Open bramaudi opened 3 months ago

bramaudi commented 3 months ago

Problem

Current auto jump behavior still let you jump on some cases which is quite annoying although I run towards 3 block height.

In the video below auto jump is behaves as expected until it auto-jumping for first time then it will keep auto-jump after I run towards the stone wall.

screenrecord

Solutions

Add more algorithm to prevent auto jump triggered when the path is 3 block height or anything impossible.

Alternatives

no alternative, we just disable it and jump manually.

Additional context

No response

Mahoyomu commented 2 months ago

I looked into the src code related to this issue and I found m_can_jump = (touching_ground || standing_node_bouncy != 0) && !m_disable_jump; According to the solution you mentioned, and the src code, I think we can add one more determine statement here to claim that only when player stands where ceiling block is about 3 blocks away can the player jump. bool could_autojump =m_can_jump && !control.jump && !control.sneak && control.isMoving(); if (!could_autojump) return; or just make another indicator that differs from m_can_jump, like m_can_auto_jump

appgurueu commented 2 months ago

Any proper implementation may not hardcode "3 blocks", but would rather have to take the player collision box, node collision boxes, and player physic properties into account to calculate whether jumping makes sense.

Mahoyomu commented 2 months ago

Any proper implementation may not hardcode "3 blocks", but would rather have to take the player collision box, node collision boxes, and player physic properties into account to calculate whether jumping makes sense.

Didn't see any code both related to m_can_jump and the player collision box when I roughly go through the src code I think maybe that can be a further work-in-progress issue, after resolving this bug by making another indicator like m_can_auto_jump real quick

Mahoyomu commented 2 months ago

I viewed the video again and I found that the bug emerged after auto-jump triggered and player not landed on the chest but the ground, which is 1 block lower than the other, that may be where the problem is So I looked into the src code and I think that's because if (!horizontal_collision) return; only considered player runs against something but not considered whether auto-jump make sense in some situation, like if there's a wall against player on the front, not a single block, then function handleAutojump should be skipped too (even if a block is on the right or on the left and auto-jump worked, that could still most possiblely be an annoying misoperation ,not a fine jump)

Mahoyomu commented 2 months ago

Please assign this issue to me, I'm already trying to fix it now, only need to know whether the position ahead of player is air block, and I can pull a request

Mahoyomu commented 1 month ago

I just tested my fix code and it works fine on this bug and I think I'm really close. After resolving its side effect which causes auto-jump behavior to be a little more unsensible, I'll start pull request.