Система со сменой колес дорабавтываю. Есть задатки системы объявлений и встречи с продавцом
This commit is contained in:
1 parent
2ce853999d
commit
27ad7eac11
25 files changed
+37130
-34404
No files matched your search
@@ -230,11 +230,26 @@ public class CarController : MonoBehaviour
|
||||
|
||||
private void UpdateWheelPose(WheelCollider collider, Transform mesh)
|
||||
{
|
||||
if (mesh == null || collider == null || !collider.enabled || !mesh.IsChildOf(transform))
|
||||
if (mesh == null || collider == null || !collider.enabled || !mesh.IsChildOf(transform))
|
||||
return;
|
||||
|
||||
collider.GetWorldPose(out Vector3 pos, out Quaternion rot);
|
||||
mesh.position = pos;
|
||||
mesh.rotation = rot;
|
||||
|
||||
// Если на эту ступицу поставили запасное колесо с противоположной стороны машины (развернутое на 180°),
|
||||
// сохраняем его разворот при вращении колеса!
|
||||
float angleDiff = Quaternion.Angle(mesh.localRotation, Quaternion.Euler(0f, 180f, 0f));
|
||||
if (angleDiff < 60f)
|
||||
mesh.rotation = rot * Quaternion.Euler(0f, 180f, 0f);
|
||||
else
|
||||
mesh.rotation = rot;
|
||||
}
|
||||
|
||||
public void ReplaceWheelMesh(WheelCollider col, Transform newMesh)
|
||||
{
|
||||
if (col == frontLeftCollider) frontLeftMesh = newMesh;
|
||||
else if (col == frontRightCollider) frontRightMesh = newMesh;
|
||||
else if (col == rearLeftCollider) rearLeftMesh = newMesh;
|
||||
else if (col == rearRightCollider) rearRightMesh = newMesh;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user