#Movement stutter

1 messages · Page 1 of 1 (latest)

cloud forge
#

I have simple scene and movement script. When I move my character stutters and when I go diagonal it doesnt truely goes diagonal.

    {
        Vector3 direction = Vector3.Zero;
        // Tuşlara göre yön belirleme
        if (Input.IsActionPressed("MoveForward"))
            direction.Z -= 1.0f;
        if (Input.IsActionPressed("MoveBackward"))
            direction.Z += 1.0f;
        if (Input.IsActionPressed("MoveLeft"))
            direction.X -= 1.0f;
        if (Input.IsActionPressed("MoveRight"))
            direction.X += 1.0f;

        if (direction != Vector3.Zero)
        {
            //Normalize to not move faster when moving diagonally
            direction.Normalized();

            //Multiply by delta to make the movement smooth and by 8 to make it faster
            direction *= (float)delta * 8;

            //Rotate the direction to the player's rotation
            direction = direction.Rotated(Vector3.Up, PlayerHandler.getPlayer(0).Rotation.Y);

            //Move the player
            PlayerHandler.getPlayer(0).MoveAndCollide(direction);
        }
    }```
chrome adder
#

The problem could be that you need to normalize after the rotation

#

That's my first guess

#

So if direction != zero, rotate it, then normalize

cloud forge
#

rotation is for moving according to players view

#

but let me try

chrome adder
#

Yeah that's what I figure. I don't see anything wrong with this as I'm reading it. Would have to honestly experiment cuz I can't get a sound handle on the math

cloud forge
#

I think this is bug in engine

#

because when I press another key it works but when I restart movement it bugs again

#

I will fill github issues tomorrow

cloud forge
#

When I remove multiplication by delta my problem is solved