public static async void Rear2Command(BasePlayer player) { var labels = new List <TextLabel>(); foreach (var vehicle in BaseVehicle.All) { var model = vehicle.Model; var size = BaseVehicle.GetModelInfo(model, VehicleModelInfoType.Size); var bumper = BaseVehicle.GetModelInfo(model, VehicleModelInfoType.RearBumperZ); var offset = new Vector3(0, -size.Y / 2, bumper.Z); var rotation = vehicle.GetRotationQuat(); //rotation = new Quaternion(-rotation.X, -rotation.Y, -rotation.Z, rotation.W); var point = vehicle.Position + Vector3.Transform(offset, rotation); labels.Add(new TextLabel("[x]", Color.Red, point, 100, 0, false)); } await Task.Delay(10000); foreach (var l in labels) { l.Dispose(); } }
public static async void RearCommand(BasePlayer player) { var labels = new List <TextLabel>(); foreach (var vehicle in BaseVehicle.All) { var model = vehicle.Model; var size = BaseVehicle.GetModelInfo(model, VehicleModelInfoType.Size); var bumper = BaseVehicle.GetModelInfo(model, VehicleModelInfoType.RearBumperZ); var offset = new Vector3(0, -size.Y / 2, bumper.Z); var rotation = vehicle.GetRotationQuat(); //rotation = new Quaternion(-rotation.X, -rotation.Y, -rotation.Z, rotation.W); var mRotation = rotation.LengthSquared > 10000 // Unoccupied vehicle updates corrupt the internal vehicle world matrix ? Matrix.CreateRotationZ(MathHelper.ToRadians(vehicle.Angle)) : Matrix.CreateFromQuaternion(rotation); var matrix = Matrix.CreateTranslation(offset) * mRotation * Matrix.CreateTranslation(vehicle.Position); var point = matrix.Translation; labels.Add(new TextLabel("[x]", Color.Blue, point, 100, 0, false)); } await Task.Delay(10000); foreach (var l in labels) { l.Dispose(); } }