using System.Collections; using System.Collections.Generic; using UnityEngine; public class Driver : MonoBehaviour { [SerializeField] float MoveSpeed = 20f; [SerializeField] float slowSpeed = 15f; [SerializeField] float boostSpeed = 30f; [SerializeField] float StearSpeed = 100f; // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { float steerAmount = Input.GetAxis("Horizontal") * StearSpeed; float MoveAmount = Input.GetAxis("Vertical") * MoveSpeed; transform.Rotate(0, 0, -steerAmount * Time.deltaTime); transform.Translate(0, MoveAmount * Time.deltaTime, 0); } void OnCollisionEnter2D(Collision2D other) { MoveSpeed = slowSpeed; } void OnTriggerEnter2D(Collider2D other) { if (other.tag == "Boost") { MoveSpeed = boostSpeed; } } }