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); } } }