Files
BABA_YAGA/Assets/Third Parties/Opsive/UltimateCharacterController/Demo/Scripts/Car/Mudguard.cs
Scove 3e39117acc Consolidate third-party plugins into Assets/Plugins
Move and consolidate many third-party plugin files and metadata from various locations (notably Assets/Third Parties/Plugins 1 and scattered Opsive/Photon folders) into a unified Assets/Plugins directory. Includes DOTween, PrimeTween, Native/BackroomsNoise, Sirenix/Odin Inspector, and Opsive UltimateCharacterController/shared libs, plus updates to several .meta files and removal of obsolete installer/legacy files. This standardizes plugin layout and cleans up duplicate/obsolete assets.
2026-06-16 18:41:44 +07:00

33 lines
1.3 KiB
C#

namespace Opsive.UltimateCharacterController.Demo.UnityStandardAssets.Vehicles.Car
{
using UnityEngine;
// this script is specific to the supplied Sample Assets car, which has mudguards over the front wheels
// which have to turn with the wheels when steering is applied.
public class Mudguard : MonoBehaviour
{
public GameObject m_Wheel; // The wheel that the script needs to referencing to get the postion for the suspension
private CarController m_CarController; // car controller to get the steering angle
private Vector3 m_TargetOriginalPosition;
private Vector3 m_OriginalPosition;
private Quaternion m_OriginalRotation;
private void Start()
{
m_CarController = GetComponentInParent<CarController>();
m_TargetOriginalPosition = m_Wheel.transform.localPosition;
m_OriginalPosition = transform.localPosition;
m_OriginalRotation = transform.localRotation;
}
private void Update()
{
transform.localPosition = m_OriginalPosition + (m_Wheel.transform.localPosition - m_TargetOriginalPosition);
transform.localRotation = m_OriginalRotation * Quaternion.Euler(0, m_CarController.CurrentSteerAngle, 0);
}
}
}