Character Controller Y location Decreasing

I have a character controller with some move scripts attached to it.

How come when I Debug.Log the transform.position.y value, the y-value is slowly decreasing? However, the controller is stable on the ground?

-Thomas

You should be using a CharacterController.Move to accomdate this.

You’ll likely have it set somewhere that

movementSpeed.y -= gravity * Time.deltaTime;

Which means that the downward force/speed due to gravity continually increases, even when the character is grounded.

When what you’ll really want is

 if ( grounded ) {
 movementSpeed.y = -gravity * Time.deltaTime;
}
else {
 movementSpeed.y -= gravity * Time.deltaTime;
}

This will increase the downward speed due to gravity only if the character isn’t on the ground. And if the character is on the ground, it will keep the downward speed locked simply to the pull of gravity (i.e. a small constant downwards force).