Question by
ronin_42 · Jul 14, 2020 at 10:50 AM ·
3daccelerationbegginer
How do i make an object accelerate to a certain speed?
I'm trying to figure out how to make my car accelerate to a speed of 40 instead of going 40 immediately after starting the simulation.
Here is my code, I can't understand how to add acceleration code lines in there, nothing I looked up on the web is helping. This is in 3D btw.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class VehicleMovement : MonoBehaviour
{
public float speed = 10;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
transform.Translate(new Vector3(0, 0, 1) * Time.deltaTime * speed);
}
}
I would be very happy if anyone can help me figure out how to make an object accelerate.
Comment