CAR GO WROOOOOOM

This commit is contained in:
magn9775
2024-03-22 11:34:56 +01:00
parent 0957f89c5c
commit a972e06a5a
2 changed files with 270 additions and 10 deletions

View File

@@ -4,15 +4,24 @@ using UnityEngine;
public class CarController : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
public WheelCollider frontLeftWheel, frontRightWheel;
public WheelCollider rearLeftWheel, rearRightWheel;
public float motorForce = 10000000f;
public float steeringAngle = 30f;
// Update is called once per frame
void Update()
{
// Motor input
float motorInput = Input.GetAxis("Vertical");
frontLeftWheel.motorTorque = motorInput * motorForce;
frontRightWheel.motorTorque = motorInput * motorForce;
// Steering input
float steeringInput = Input.GetAxis("Horizontal");
frontLeftWheel.steerAngle = steeringInput * steeringAngle;
frontRightWheel.steerAngle = steeringInput * steeringAngle;
// Move camera
}
}