Files
CityDrivingSimulator.Unity/Unity/Assets/Scripts/WheelTransformController.cs
T

28 lines
680 B
C#
Raw Normal View History

2025-05-13 03:19:28 +03:00
using UnityEngine;
using System.Collections;
public class WheelTransformController : MonoBehaviour {
public WheelPhysics wheel;
public bool flipTotation;
private Quaternion _startupRotation;
// Use this for initialization
void Start () {
_startupRotation = transform.localRotation;
}
// Update is called once per frame
void Update () {
if(wheel == null) {
return;
}
float angle = Mathf.Repeat((float)wheel.angle *Mathf.Rad2Deg, 360.0f);
if(flipTotation) {
angle = -angle;
}
transform.localRotation = _startupRotation * Quaternion.AngleAxis(angle, Vector3.right);
}
}