public static bool CheckSafetyDistanceOfObstacle(this SafetyModule safetyModule, VPVehicleController carController, IObstacle obstacle) { var distanceOfObstacle = carController.GetDistance(obstacle); var brakingDistance = safetyModule.BrakingDistance; //TODO dystans wyliczany powinnien być zgodnie z trajektorią ruchu nie po lini prostej return(distanceOfObstacle.magnitude > brakingDistance + safetyModule.SafetyDistance); }
public override void OnEnableVehicle() { m_vehicle = vehicle.GetComponent <VPVehicleController>(); if (m_vehicle == null) { DebugLogWarning("This component requires a VPVehicleController-based vehicle. Component disabled"); enabled = false; return; } m_deviceInput = vehicle.GetComponentInChildren <VPDeviceInput>(); }
public static void StopACar(this VPStandardInput input, VPVehicleController carController) { //TODO zrobić płynne hamowanie przez użycie PIDA input.externalBrake = carController.brakes.maxBrakeTorque; input.externalClutch = 1; }
public static Vector3 GetDistance(this VPVehicleController safetyModule, IObstacle obstacle) { var obstaclePosition = new Vector3(obstacle.X, obstacle.Y, obstacle.Z); return(safetyModule.transform.position - obstaclePosition); }