mirror of
https://github.com/GTA-ASM/SanAndreasUnity
synced 2024-11-22 20:13:02 +00:00
Apply "Disable vehicle's rigid body on clients" setting immediately
This commit is contained in:
parent
d91cd759e3
commit
aeb0c8fc1e
3 changed files with 24 additions and 6 deletions
|
@ -210,21 +210,19 @@ namespace SanAndreasUnity.Behaviours.Vehicles
|
|||
m_vehicle.Braking = brake;
|
||||
}
|
||||
|
||||
void EnableOrDisableRigidBody()
|
||||
public void EnableOrDisableRigidBody()
|
||||
{
|
||||
if (NetStatus.IsServer || this.IsControlledByLocalPlayer)
|
||||
{
|
||||
// enable rigid body
|
||||
m_vehicle.RigidBody.isKinematic = false;
|
||||
m_vehicle.RigidBody.detectCollisions = true;
|
||||
F.EnableRigidBody(m_vehicle.RigidBody);
|
||||
}
|
||||
else
|
||||
{
|
||||
// disable rigid body
|
||||
if (VehicleManager.Instance.disableRigidBodyOnClients)
|
||||
{
|
||||
m_vehicle.RigidBody.isKinematic = true;
|
||||
m_vehicle.RigidBody.detectCollisions = false;
|
||||
F.DisableRigidBody(m_vehicle.RigidBody);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -90,7 +90,7 @@ namespace SanAndreasUnity.Settings {
|
|||
OptionsWindow.BoolInput m_disableVehiclesRigidBodyOnClients = new OptionsWindow.BoolInput ("Disable vehicle's rigid body on clients") {
|
||||
isAvailable = () => VehicleManager.Instance != null,
|
||||
getValue = () => VehicleManager.Instance.disableRigidBodyOnClients,
|
||||
setValue = (value) => { VehicleManager.Instance.disableRigidBodyOnClients = value; },
|
||||
setValue = (value) => { ApplyRigidBodyState(value); },
|
||||
persistType = OptionsWindow.InputPersistType.OnStart
|
||||
};
|
||||
OptionsWindow.BoolInput m_syncPedTransformWhileInVehicle = new OptionsWindow.BoolInput ("Sync ped transform while in vehicle") {
|
||||
|
@ -142,6 +142,13 @@ namespace SanAndreasUnity.Settings {
|
|||
}
|
||||
}
|
||||
|
||||
static void ApplyRigidBodyState(bool bDisabled)
|
||||
{
|
||||
VehicleManager.Instance.disableRigidBodyOnClients = bDisabled;
|
||||
foreach (var v in Vehicle.AllVehicles)
|
||||
v.GetComponent<VehicleController>().EnableOrDisableRigidBody();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -273,6 +273,19 @@ namespace SanAndreasUnity.Utilities
|
|||
}
|
||||
|
||||
|
||||
public static void EnableRigidBody(Rigidbody rb)
|
||||
{
|
||||
rb.isKinematic = false;
|
||||
rb.detectCollisions = true;
|
||||
}
|
||||
|
||||
public static void DisableRigidBody(Rigidbody rb)
|
||||
{
|
||||
rb.isKinematic = true;
|
||||
rb.detectCollisions = false;
|
||||
}
|
||||
|
||||
|
||||
public static object FromHex(this string hexString, Type type, CultureInfo info)
|
||||
{
|
||||
var argTypes = new[] { typeof(string), typeof(NumberStyles), typeof(IFormatProvider) };
|
||||
|
|
Loading…
Reference in a new issue