# Rigidbody accelerating too fast

I am new to unity and stuck here. A cube sliding on a plane with zero friction accelerates too fast. I need it to gradually increase in the z axis. Also the movement in x axis should affect the speed. The Left() and Right() are given to buttons.

``````using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Move : MonoBehaviour {

public Rigidbody rb;
public float ff = 1000f;
public float dk = 200f;

void FixedUpdate()
{

}
public void Left()
{

rb.AddForce(dk * Time.deltaTime, 0, 0, ForceMode.VelocityChange);

}
public void Right()
{

rb.AddForce(-dk * Time.deltaTime, 0, 0, ForceMode.VelocityChange);

}
}
``````

Left and right are already affecting the speed, are they not?
As for increasing over time, this is something simple… it accelerates at a fixed rate.

``````public Rigidbody rb;
public float speed = 0;
private void FixedUpdate()
{
speed += Time.deltaTime;
speed = Mathf.Clamp(speed, 0, 10);
rb.AddForce(0, 0, speed, ForceMode.VelocityChange); // alter the force mode if you want mass to affect it.
}
``````

Not sure if this is helpful, but you could artificially slow down the speed up the time…

``````public Rigidbody rb;
public float speed = 0;
float nextBoost = 0;
private void FixedUpdate()
{
if (Time.time >= nextBoost)
{
speed += Time.deltaTime * 3; // with just delta time it seemed slow to reach '10' for me, but you can play around with the numbers/delay.
speed = Mathf.Clamp(speed, 0, 10);