I am trying to make a simple car game in Unity.
I want to make a car controller such that it can move forward and in X direction.
for moving car in X direction i am using
i can use the same for forward but i want it to accelerate its velocity relatively with time and to stop slightly on applying brake which is not possible in transform.translate.forward help me in doing this.
private Rigidbody rb;
rb = GetComponent<Rigidbody>();
rb.velocity *= 0.9f; // it will slow down until it stops completly, if you multiply it by lets say 1.1f then it will accelerate
If you want to have maximum speed you can change rb.velocity.magnitude and if it increases certein speed then you can stop accelerating etc.
why it’ll accelerate when u multiply by somthing bigger @mlnczk ,why it will accelerate when u multiply by 1.1f
There’s also another solution to this. You can use Unitys lerp functions. When combined with time you can manipulate simple transforms such as transform translate. I do not have the code for this but search it up on google if you don’t want it to be physicsbased.