mirror of
https://github.com/GTA-ASM/SanAndreasUnity
synced 2024-11-15 00:37:09 +00:00
Apply sync rate on start
This commit is contained in:
parent
06af108c8e
commit
0e6f471db6
2 changed files with 17 additions and 2 deletions
|
@ -183,6 +183,11 @@ namespace SanAndreasUnity.Behaviours.Vehicles
|
|||
s_vehicles.Remove(this);
|
||||
}
|
||||
|
||||
void Start()
|
||||
{
|
||||
this.ApplySyncRate(VehicleManager.Instance.vehicleSyncRate);
|
||||
}
|
||||
|
||||
public void SetColors(params int[] clrIndices)
|
||||
{
|
||||
for (var i = 0; i < 4 && i < clrIndices.Length; ++i)
|
||||
|
@ -423,5 +428,16 @@ namespace SanAndreasUnity.Behaviours.Vehicles
|
|||
if (blinkerMode != VehicleBlinkerMode.None)
|
||||
blinkerMode = VehicleBlinkerMode.None;
|
||||
}
|
||||
|
||||
public void ApplySyncRate(float syncRate)
|
||||
{
|
||||
foreach (var comp in this.GetComponents<Mirror.NetworkBehaviour>())
|
||||
comp.syncInterval = 1.0f / syncRate;
|
||||
|
||||
// also assign it to NetworkTransform, because it may be disabled
|
||||
if (this.NetTransform != null)
|
||||
this.NetTransform.syncInterval = 1.0f / syncRate;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -110,8 +110,7 @@ namespace SanAndreasUnity.Settings {
|
|||
VehicleManager.Instance.vehicleSyncRate = syncRate;
|
||||
foreach (var v in Vehicle.AllVehicles)
|
||||
{
|
||||
foreach (var comp in v.GetComponents<Mirror.NetworkBehaviour>())
|
||||
comp.syncInterval = 1.0f / syncRate;
|
||||
v.ApplySyncRate(syncRate);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue