Hi i am making a racing type game and i would like to know how to make a timer that starts when the car starts moving is that possible and if so how would i do it.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Car : MonoBehaviour {
private Rigidbody carRigid;
public int speed;
public int rotatespeed;
// Use this for initialization
void Start () {
carRigid = GetComponent<Rigidbody> ();
}
// Update is called once per frame
void Update () {
}
void FixedUpdate (){
if (Input.GetButton ("Drive")) {
carRigid.AddForce (transform.forward * speed * Time.deltaTime);
}
if (Input.GetButton ("Reverse")) {
carRigid.AddForce (transform.forward * -speed * Time.deltaTime);
}
if (Input.GetButton ("Left")) {
transform.Rotate (0, -rotatespeed, 0);
}
if (Input.GetButton ("Right")) {
transform.Rotate (0, rotatespeed, 0);
}
}
}