diff --git a/Assets/AWSIM/Scripts/RandomTraffic/NPCVehicle/NPCVehicleInternalState.cs b/Assets/AWSIM/Scripts/RandomTraffic/NPCVehicle/NPCVehicleInternalState.cs index ed9fe6aad..91513665c 100644 --- a/Assets/AWSIM/Scripts/RandomTraffic/NPCVehicle/NPCVehicleInternalState.cs +++ b/Assets/AWSIM/Scripts/RandomTraffic/NPCVehicle/NPCVehicleInternalState.cs @@ -109,7 +109,7 @@ public float DistanceToNextLane => CalculateDistanceToNextLane(); public float DistanceToIntersection => FirstLaneWithIntersection == null ? float.MaxValue - : DistanceToClosestTrafficLane(); + : DistanceToClosestTrafficLightLane(); public bool ObstructedByVehicleBehindIntersection => DistanceToIntersection > DistanceToFrontVehicle; @@ -143,7 +143,7 @@ private float CalculateDistanceToNextLane() return (1f - laneFollowingProgress) * laneLenght; } - public float DistanceToClosestTrafficLane() + public float DistanceToClosestTrafficLightLane() { if (TrafficLightLane is null && !FollowingLanes.Contains(TrafficLightLane)) { @@ -179,12 +179,9 @@ public float DistanceToClosestTrafficLane() } else { - //when distance was calculated once partially/for whole lane it keeps calculating whole lanes - //until meeting traffic light lane distance += laneLenght; } - //if traffic lane, stop computing if (FollowingLanes[i] == TrafficLightLane) { break;