Home > OS >  why does the jump occur at different lengths?
why does the jump occur at different lengths?

Time:05-31

the player jumps to 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);
    }

How to fix it?

CodePudding user response:

You probably used that 'MoveUp' function in 'Update' function or once key is pressed. In that case, there could be a possibility that 'MoveUp' function is invoked multiple time according the the frame rate or the input time.

To avoid that, you can use keyDown function, or properly invoke that function only one time.

  • Related