29 lines
726 B
C#
29 lines
726 B
C#
using UnityEngine;
|
|
|
|
public class WheelVisuals : MonoBehaviour
|
|
{
|
|
[System.Serializable]
|
|
public struct WheelPair
|
|
{
|
|
public WheelCollider collider;
|
|
public Transform mesh;
|
|
}
|
|
|
|
[Header("Привязка колес")]
|
|
public WheelPair[] wheels;
|
|
|
|
private void Update()
|
|
{
|
|
foreach (var w in wheels)
|
|
{
|
|
if (w.collider == null || w.mesh == null) continue;
|
|
|
|
// Получаем физическую позицию колеса
|
|
w.collider.GetWorldPose(out Vector3 pos, out Quaternion rot);
|
|
|
|
// Применяем к 3D-модели
|
|
w.mesh.position = pos;
|
|
w.mesh.rotation = rot;
|
|
}
|
|
}
|
|
} |