1 using System;
2 using
UnityEngine;
3
4 namespace
UnityStandardAssets.Vehicles.Car
5 {
6     
// this script is specific to the supplied Sample Assets car, which has mudguards over the front wheels
7     
// which have to turn with the wheels when steering is applied.
8
9     
public class Mudguard : MonoBehaviour
10     {
11         
public CarController carController; // car controller to get the steering angle
12
13         
private Quaternion m_OriginalRotation;
14
15
16         
private void Start()
17         {
18             m_OriginalRotation = transform.localRotation;
19         }
20
21
22         
private void Update()
23         {
24             transform.localRotation = m_OriginalRotation*Quaternion.Euler(
0, carController.CurrentSteerAngle, 0);
25         }
26     }
27 }


Tìm kết quả nhanh