using System.Collections; using System.Collections.Generic; using UnityEngine; [System.Serializable] public class Wheel { [SerializeField] private WheelCollider collider; [SerializeField] private Transform wheel; [SerializeField] private float wheelSize = 15; //default size change to what the actual size is public float GetWheelRPM(){ return collider.rpm; } //return the wheels current rpm public void ApplySteerAngle(float steerAngle){ //apply steer angle to wheel to rotate collider.steerAngle = steerAngle; } public void ApplyBrakeForce(float brakeForce){ //apply brake force to the wheel collider.brakeTorque = brakeForce; } public void ApplyAcceleration(float acceleration){ //apply acceleration value to the wheel collider.motorTorque = acceleration; } public void UpdateWheel(){ //rotates the wheel when the car is moving Vector3 position; Quaternion rotation; collider.GetWorldPose(out position, out rotation); wheel.position = position; wheel.rotation = rotation; } }