From c2b26c0491886b99f422e830cd9ec1637a4ddc2e Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Sun, 1 Mar 2026 09:36:29 +0800 Subject: first --- Assets/Scripts/GamePlay/Player/WheelTransforms.cs | 48 +++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 Assets/Scripts/GamePlay/Player/WheelTransforms.cs (limited to 'Assets/Scripts/GamePlay/Player/WheelTransforms.cs') diff --git a/Assets/Scripts/GamePlay/Player/WheelTransforms.cs b/Assets/Scripts/GamePlay/Player/WheelTransforms.cs new file mode 100644 index 0000000..0834f32 --- /dev/null +++ b/Assets/Scripts/GamePlay/Player/WheelTransforms.cs @@ -0,0 +1,48 @@ +using System; +using UnityEngine; + +namespace GamePlay.Player +{ + [ExecuteAlways] + public class WheelTransforms : MonoBehaviour + { + [Header("Parameters")] + [Range(0f, 4f)] public float length; + [Range(0f, 4f)] public float width; + [Range(-5f, 5f)] public float offsetX; + [Range(-5f, 5f)] public float offsetZ; + [Range(-5f, 5f)] public float offsetY; + + [Header("Bindings")] + public Transform frontLeft; + public Transform frontRight; + public Transform rearLeft; + public Transform rearRight; + +#if UNITY_EDITOR + private void Update() + { + if (Application.isPlaying) return; + UpdateWheels(); + } +#endif + + private void FixedUpdate() + { + UpdateWheels(); + } + + private void UpdateWheels() + { + frontLeft.localPosition = GetPosition(-1, 1); + frontRight.localPosition = GetPosition(1, 1); + rearLeft.localPosition = GetPosition(-1, -1); + rearRight.localPosition = GetPosition(1, -1); + } + + private Vector3 GetPosition(float axisX, float axisZ) + { + return new Vector3(width / 2 * axisX + offsetX, offsetY, length / 2 * axisZ + offsetZ); + } + } +} -- cgit