Slow down acceleration

Hello Unity Community,

I have a script that has an object accelerate but my problem is that it accelerates to fast. How can I slow down the acceleration? I figured I could do something with the modulus operator but I can’t seem to figure it out. Here’s my code:

using UnityEngine;
using System.Collections;

public class MoveForward : MonoBehaviour {
	public float speed = 6.0F;
	public float jumpSpeed = 8.0F;
	public float gravity = 20.0F;
	private Vector3 moveDirection =;
	public int i;
	public int MaxSpeed = 500;
	public int MinSpeed = 5;
	// Update is called once per frame
	void FixedUpdate () {
		CharacterController controller = GetComponent<CharacterController>();
		 if (controller.isGrounded) {
			moveDirection = new Vector3(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"), (2*i)/100);
			moveDirection = transform.TransformDirection(moveDirection);
			moveDirection *= speed;
			 if (Input.GetButton("Jump"))
				moveDirection.y = jumpSpeed;
			if (i < MaxSpeed){
				print (i);
		moveDirection.y -= gravity * Time.deltaTime;
		controller.Move(moveDirection * Time.deltaTime);	


The i variable is what’s making the object accelerate. The i with the if statement is where I need to put my code for slowing down acceleration. Any help by you fine folks is appreciated. :slight_smile:

um no its not
i is doing nothing
the only thing affecting your speed / acceleration is


which you can change

now I dont know what the physics looks like on your side
but if you say it is accelerating then you can just change speed

if it isnt accelerating
I recommend looking into MathF.Lerp
and lerping the speed

edit: maybe I should explain the script to you

charactercontroller.move is what makes your character move
movedirection is the math data that is passed to it to move it by whatever you want
as far as i can see i never influences movedirection or any of the variables that influence moveDirection