mirror of
https://github.com/GTA-ASM/SanAndreasUnity
synced 2024-11-26 22:10:17 +00:00
sync vehicle's health
This commit is contained in:
parent
2e0108d662
commit
96829ef506
1 changed files with 4 additions and 0 deletions
|
@ -21,6 +21,7 @@ namespace SanAndreasUnity.Behaviours.Vehicles
|
|||
[SyncVar(hook=nameof(OnNetRotationChanged))] Quaternion m_net_rotation;
|
||||
[SyncVar] Vector3 m_net_linearVelocity;
|
||||
[SyncVar] Vector3 m_net_angularVelocity;
|
||||
[SyncVar] float m_net_health;
|
||||
|
||||
struct WheelSyncData
|
||||
{
|
||||
|
@ -145,6 +146,7 @@ namespace SanAndreasUnity.Behaviours.Vehicles
|
|||
m_net_rotation = m_vehicle.transform.rotation;
|
||||
m_net_linearVelocity = m_vehicle.RigidBody.velocity;
|
||||
m_net_angularVelocity = m_vehicle.RigidBody.angularVelocity;
|
||||
m_net_health = m_vehicle.Health;
|
||||
|
||||
// wheels
|
||||
m_net_wheelsData.Flush(); // remove current list of changes - this ensures that only the current wheel state is sent, and prevents memory leak bug in Mirror
|
||||
|
@ -188,6 +190,8 @@ namespace SanAndreasUnity.Behaviours.Vehicles
|
|||
m_vehicle.RigidBody.velocity = m_net_linearVelocity;
|
||||
if (VehicleManager.Instance.syncAngularVelocity)
|
||||
m_vehicle.RigidBody.angularVelocity = m_net_angularVelocity;
|
||||
|
||||
m_vehicle.Health = m_net_health;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue