This commit is contained in:
2025-05-13 03:19:28 +03:00
parent e2847b060d
commit 762dcf4524
784 changed files with 542617 additions and 2 deletions
+33
View File
@@ -0,0 +1,33 @@
using UnityEngine;
using System.Collections;
using System;
public class SteeringWheel : MonoBehaviour{
public GameObject Target;
private Quaternion InitialRotation;
private Vector3 InitialPosition;
public float degrees = 900;
public void ResetRotation(){
Target.transform.localRotation = InitialRotation;
}
public void SetAngle(float angle)
{
var halfDegrees = degrees*0.5f;
angle = Mathf.Clamp(angle, -halfDegrees, halfDegrees);
ResetRotation();
Target.transform.Rotate(0, angle, 0);
}
public void Start(){
if (Target != null) {
InitialRotation = Target.transform.localRotation;
InitialPosition = Target.transform.localPosition;
} else {
Debug.LogWarning("Steering wheel target is not assigned");
}
}
}