Vehicle sync update
This commit is contained in:
@ -42,6 +42,8 @@ namespace CoopClient
|
||||
public Blip PedBlip;
|
||||
|
||||
#region -- IN VEHICLE --
|
||||
private int VehicleStopTime { get; set; }
|
||||
|
||||
public bool IsInVehicle { get; set; }
|
||||
public int VehicleModelHash { get; set; }
|
||||
public int VehicleSeatIndex { get; set; }
|
||||
@ -273,18 +275,30 @@ namespace CoopClient
|
||||
MainVehicle.AreHighBeamsOn = CurrentVehAreHighBeamsOn;
|
||||
}
|
||||
|
||||
MainVehicle.SteeringAngle = VehicleSteeringAngle;
|
||||
if (VehicleSteeringAngle != MainVehicle.SteeringAngle)
|
||||
{
|
||||
MainVehicle.SteeringAngle = VehicleSteeringAngle;
|
||||
}
|
||||
|
||||
if (VehicleSpeed > 0.2f)
|
||||
// Good enough for now, but we need to create a better sync
|
||||
if (VehicleSpeed > 0.2f && MainVehicle.IsInRange(VehiclePosition, 7.0f))
|
||||
{
|
||||
MainVehicle.Velocity = VehicleVelocity + (VehiclePosition - MainVehicle.Position);
|
||||
MainVehicle.Quaternion = Quaternion.Slerp(MainVehicle.Quaternion, VehicleRotation, 0.25f);
|
||||
|
||||
VehicleStopTime = Environment.TickCount;
|
||||
}
|
||||
else if ((Environment.TickCount - VehicleStopTime) <= 1000)
|
||||
{
|
||||
Vector3 posTarget = Util.LinearVectorLerp(MainVehicle.Position, VehiclePosition + (VehiclePosition - MainVehicle.Position), (Environment.TickCount - VehicleStopTime), 1000);
|
||||
MainVehicle.PositionNoOffset = posTarget;
|
||||
MainVehicle.Quaternion = Quaternion.Slerp(MainVehicle.Quaternion, VehicleRotation, 0.5f);
|
||||
}
|
||||
else
|
||||
{
|
||||
MainVehicle.Position = VehiclePosition;
|
||||
MainVehicle.Quaternion = VehicleRotation;
|
||||
}
|
||||
|
||||
MainVehicle.Quaternion = VehicleRotation;
|
||||
#endregion
|
||||
}
|
||||
|
||||
@ -295,6 +309,11 @@ namespace CoopClient
|
||||
Character.Task.LeaveVehicle();
|
||||
}
|
||||
|
||||
if (MainVehicle != null)
|
||||
{
|
||||
MainVehicle = null;
|
||||
}
|
||||
|
||||
if (IsOnFire && !Character.IsOnFire)
|
||||
{
|
||||
Character.IsInvincible = false;
|
||||
|
@ -11,6 +11,21 @@ namespace CoopClient
|
||||
{
|
||||
class Util
|
||||
{
|
||||
public static Vector3 LinearVectorLerp(Vector3 start, Vector3 end, int currentTime, int duration)
|
||||
{
|
||||
return new Vector3()
|
||||
{
|
||||
X = LinearFloatLerp(start.X, end.X, currentTime, duration),
|
||||
Y = LinearFloatLerp(start.Y, end.Y, currentTime, duration),
|
||||
Z = LinearFloatLerp(start.Z, end.Z, currentTime, duration),
|
||||
};
|
||||
}
|
||||
|
||||
public static float LinearFloatLerp(float start, float end, int currentTime, int duration)
|
||||
{
|
||||
return (end - start) * currentTime / duration + start;
|
||||
}
|
||||
|
||||
public static byte GetPedSpeed(Ped ped)
|
||||
{
|
||||
if (ped.IsSprinting)
|
||||
|
Reference in New Issue
Block a user