0

我遇到了一个问题,因为我的缓冲区,我的播放器对象在跳跃时总是跳到最大高度。这是我的第一场比赛,所以我在玩 Heartbeast 的引擎。我想我错过了一些相当明显的东西,只是希望你们能提供帮助!

这是我在跳跃动作脚本中使用的内容:


///enable_movement_jump(height, input, release_input)
/*
    Call this script to enable platform jumping
    on a movement entity.
*/

var height = argument[0]; // The jump height (Should be positive)
var input = argument[1]; // The input for jumping
var release_input = argument[2]; // The input for jump height control (release)
var coyoteFrames = 10; // The grace period, in frames, for coyote time
var jumpBufferFrames = 10; // The buffer, in frames, for the jump buffer

// Check for ground collision
if (place_meeting(x, y+1, collision_object) || place_meeting(xprevious, yprevious+1, collision_object)) {
    coyoteTimer = 0; // Reset coyote timer
    if ((input) || (jumpBufferTimer < jumpBufferFrames))
    {
        vsp[0] = -height;
        coyoteTimer = coyoteFrames; // Max coyote timer
        jumpBufferTimer = jumpBufferFrames; // Max buffer timer
    }

} else {
    if (input)
    {
        jumpBufferTimer = 0; // Reset buffer timer
        if (coyoteTimer < coyoteFrames) // During coyote time
        {
            vsp[0] = -height;
            coyoteTimer = coyoteFrames; // Max coyote timer
            jumpBufferTimer = jumpBufferFrames; // Max buffer timer
        }
    }
    if (release_input && vsp[0] <= -height/3) {
        vsp[0] = -height/3;
    }
}

++coyoteTimer; // Increase coyote
++jumpBufferTimer; // Increase buffer

4

1 回答 1

0

当你撞到地面时,你重置了coyoteTimer,但是你将 置于jumpBufferTimer不同的条件下,也许这些应该在相同的条件下设置为 0?

于 2020-02-25T10:40:39.170 回答