sync y position of wheel

This commit is contained in:
in0finite 2021-02-04 22:21:16 +01:00
parent 91bc7547a5
commit f6fe21cbdb
2 changed files with 10 additions and 0 deletions

View file

@ -29,6 +29,7 @@ namespace SanAndreasUnity.Behaviours.Vehicles
public float motorTorque;
public float steerAngle;
//public float travel;
public float localPosY;
}
class WheelSyncList : SyncList<WheelSyncData> { }
@ -166,6 +167,7 @@ namespace SanAndreasUnity.Behaviours.Vehicles
motorTorque = wheel.Collider.motorTorque,
steerAngle = wheel.Collider.steerAngle,
//travel = wheel.Travel,
localPosY = wheel.Collider.transform.GetChild(0).localPosition.y,
});
}
}
@ -189,6 +191,7 @@ namespace SanAndreasUnity.Behaviours.Vehicles
w.Collider.motorTorque = data.motorTorque;
w.Collider.steerAngle = data.steerAngle;
//w.Travel = data.travel;
w.Collider.transform.GetChild(0).SetLocalY(data.localPosY);
}
}

View file

@ -263,6 +263,13 @@ namespace SanAndreasUnity.Utilities
t.position = pos;
}
public static void SetLocalY(this Transform t, float yPos)
{
Vector3 pos = t.localPosition;
pos.y = yPos;
t.localPosition = pos;
}
public static float Distance(this Transform t, Vector3 pos)
{
return Vector3.Distance (t.position, pos);