Mudguard.cs 723 B

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