Untitled
unknown
plain_text
2 years ago
585 B
6
Indexable
using UnityEngine; public class CarController : MonoBehaviour { public float speed = 10f; public float rotationSpeed = 100f; private void Update() { // Get user input for movement and rotation float moveInput = Input.GetAxis("Vertical"); float rotateInput = Input.GetAxis("Horizontal"); // Move the car forward/backward transform.Translate(Vector3.forward * moveInput * speed * Time.deltaTime); // Rotate the car left/right transform.Rotate(Vector3.up * rotateInput * rotationSpeed * Time.deltaTime); } }
Editor is loading...