mirror of
https://github.com/GTA-ASM/SanAndreasUnity
synced 2024-11-26 22:10:17 +00:00
add option to destroy wheel colliders on client
This commit is contained in:
parent
c6bd9fef9a
commit
c4699859e1
3 changed files with 26 additions and 5 deletions
|
@ -67,6 +67,14 @@ namespace SanAndreasUnity.Behaviours.Vehicles
|
|||
|
||||
// update rigid body status
|
||||
this.EnableOrDisableRigidBody();
|
||||
|
||||
if (VehicleManager.Instance.destroyWheelCollidersOnClient)
|
||||
{
|
||||
foreach (var wheelCollider in this.GetComponentsInChildren<WheelCollider>())
|
||||
{
|
||||
Destroy(wheelCollider);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -168,7 +176,7 @@ namespace SanAndreasUnity.Behaviours.Vehicles
|
|||
motorTorque = wheel.Collider.motorTorque,
|
||||
steerAngle = wheel.Collider.steerAngle,
|
||||
//travel = wheel.Travel,
|
||||
localPosY = wheel.Collider.transform.GetChild(0).localPosition.y,
|
||||
localPosY = wheel.Child.localPosition.y,
|
||||
rpm = wheel.Collider.rpm,
|
||||
});
|
||||
}
|
||||
|
@ -189,11 +197,15 @@ namespace SanAndreasUnity.Behaviours.Vehicles
|
|||
for (int i=0; i < m_vehicle.Wheels.Count && i < m_net_wheelsData.Count; i++) {
|
||||
var w = m_vehicle.Wheels[i];
|
||||
var data = m_net_wheelsData[i];
|
||||
w.Collider.brakeTorque = data.brakeTorque;
|
||||
w.Collider.motorTorque = data.motorTorque;
|
||||
w.Collider.steerAngle = data.steerAngle;
|
||||
|
||||
if (w.Collider != null)
|
||||
{
|
||||
w.Collider.brakeTorque = data.brakeTorque;
|
||||
w.Collider.motorTorque = data.motorTorque;
|
||||
w.Collider.steerAngle = data.steerAngle;
|
||||
}
|
||||
//w.Travel = data.travel;
|
||||
w.Collider.transform.GetChild(0).SetLocalY(data.localPosY);
|
||||
w.Child.SetLocalY(data.localPosY);
|
||||
Vehicle.UpdateWheelRotation(w, data.rpm, data.steerAngle);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ namespace SanAndreasUnity.Behaviours.Vehicles
|
|||
public bool syncVehicleTransformUsingSyncVars = false;
|
||||
public bool controlInputOnLocalPlayer = true;
|
||||
public bool controlWheelsOnLocalPlayer = true;
|
||||
public bool destroyWheelCollidersOnClient = true;
|
||||
|
||||
public float vehicleSyncRate = 20;
|
||||
|
||||
|
|
|
@ -55,6 +55,13 @@ namespace SanAndreasUnity.Settings
|
|||
setValue = (value) => { VehicleManager.Instance.controlWheelsOnLocalPlayer = value; },
|
||||
persistType = OptionsWindow.InputPersistType.OnStart
|
||||
};
|
||||
OptionsWindow.BoolInput m_destroyWheelCollidersOnClient = new OptionsWindow.BoolInput
|
||||
{
|
||||
description = "Destroy wheel colliders on client",
|
||||
getValue = () => VehicleManager.Instance.destroyWheelCollidersOnClient,
|
||||
setValue = (value) => { VehicleManager.Instance.destroyWheelCollidersOnClient = value; },
|
||||
persistType = OptionsWindow.InputPersistType.OnStart,
|
||||
};
|
||||
OptionsWindow.BoolInput m_controlVehicleInputOnLocalPlayer = new OptionsWindow.BoolInput ("Control vehicle input on local player") {
|
||||
isAvailable = () => VehicleManager.Instance != null,
|
||||
getValue = () => VehicleManager.Instance.controlInputOnLocalPlayer,
|
||||
|
@ -99,6 +106,7 @@ namespace SanAndreasUnity.Settings
|
|||
m_syncVehiclesLinearVelocity,
|
||||
m_syncVehiclesAngularVelocity,
|
||||
m_controlWheelsOnLocalPlayer,
|
||||
m_destroyWheelCollidersOnClient,
|
||||
m_controlVehicleInputOnLocalPlayer,
|
||||
m_whenToDisableVehiclesRigidBody,
|
||||
m_vehicleRigidBodyInterpolationModeOnServer,
|
||||
|
|
Loading…
Reference in a new issue