CharacterController.Move() moves player upward

Hey guys, just trying to get some simple movement in using the CharacterController.Move() function.
It works, sort of.
the player moves forward, but also moves upwards on the Y axis for some unknown reason.
The movement code is:

*moveDirection = transform.TransformDirection(Vector3.forward);
moveDirection *= walkspeed;
moveDirection.y -= gravity * Time.deltaTime;
controller.Move( moveDirection * Time.deltaTime );*

I’ve been watching the Y co-ords in the editor and it always snaps to -11.55 every time i hold the button to move, but after releasing the button the character will fall back down to the ground.

Any help figuring out why would be greatly appreciated.
Thank you

moveDirection.y -= gravity * Time.deltaTime;

I Believe that line is causing problem for you, since you’re also multiplying with deltaTime in the controller.Move() line.

Try this instead.

moveDirection.y = -gravity;

controller.Move( moveDirection * Time.deltaTime );