Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

it seems there is a error with the movement code where the player moves at different speeds than usual, I have zero idea why and im sorry if it effects you

(here is the code if you want to help figure the problem out)

//movement

        float hv = Input.GetAxis("Horizontal") * Time.deltaTime * movementSpeed;

        float yv = Input.GetAxis("Vertical") * Time.deltaTime * movementSpeed;

        if (new Vector2(hv, yv).magnitude > 0.6)

        {

            rb.velocity = Vector3.up * rb.velocity.y + hv * transform.right + yv * transform.forward;

        }

        if(Input.GetButton("Jump"))

        {

            if (Physics.Raycast(new Ray(transform.position, Vector3.down), out RaycastHit hit, 1f))

            {

                rb.velocity = new Vector3(rb.velocity.x, jumpHeight, rb.velocity.z);

            }

        }

Just realized that with setting the velocity of a rigid body you don’t multiply by time . DeltaTime because the rigid body already is doing it for you