Where should the Acceleration Go?!
Hello, So I've been stuck on coding my game for a while now, and was wondering if anyone here might help me out. First off of course, I'm trying to make a basic car controller similar to those used for Mario kart 64, where can accelerate forwards but can't back up(I think). You also can turn either left or right, as well as preform drifting actions, which if perform right can give you a decent speed boost. now as you can see in the Sample script provided below, I setup basic player movement that allows the player to move forward and back, as well as turn either left or right. Right now, I need to figure out a where to put things like acceleration, a break system, and perhaps something along the lines of drifting mechanics. More over, how should I setup said systems for my player script?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CarController : MonoBehaviour {
public float speed = 10.0f;
public float rotationSpeed = 100.0f;
void Update(){
float translation = Input.GetAxis("Vertical") * speed;
float rotation = Input.GetAxis("Horizontal") * rotationSpeed;
translation *= Time.deltaTime;
rotation *= Time.deltaTime;
transform.Translate(0, 0, translation);
transform.Rotate(0, rotation, 0);
}
}
So anyway, does someone have any suggestions, or perhaps a bit of advice?