*
This commit is contained in:
@@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user