为什么跳跃发生在不同的长度?

why does the jump occur at different lengths?

玩家跳到不同的长度

    public float speedStep = 100f;
    public float powerJump = 100f;
    public void MoveUp()
    {
        transform.Translate(Vector3.forward * speedStep * Time.deltaTime);
        transform.Translate(Vector3.up * powerJump * Time.deltaTime);
    }

如何解决?

您可能在 'Update' 函数中使用了 'MoveUp' 函数,或者在按下某个键时使用了该函数。在这种情况下,可能会根据帧速率或输入时间多次调用 'MoveUp' 函数。

为避免这种情况,您可以使用 keyDown 函数,或仅正确调用该函数一次。