Luft08 27 Posted August 22 I'm trying to write a function to alert me when a vehicle is approaching a stop sign. I'm having difficulty finding a way to determine if the sign is facing the vehicle. What I have so far: LFT_ShouldReactToSign = { params ["_vehicle", "_signClassName", "_detectionRange"]; // Get the model path from the class name private _signModelPath = getText (configFile >> "CfgVehicles" >> _signClassName >> "model"); // Get the position and direction of the vehicle private _vehiclePos = getPos _vehicle; private _vehicleDir = getDir _vehicle; // Log vehicle direction for debugging diag_log format ["Vehicle Direction: %1", _vehicleDir]; // Find the nearest objects within the specified detection range private _nearbyObjects = nearestObjects [_vehiclePos, [], _detectionRange]; // Check each object to see if it matches the sign model path { private _objectModelInfo = getModelInfo _x; private _objectModelPath = _objectModelInfo select 1; if (_objectModelPath == _signModelPath) then { private _signPos = getPos _x; private _signDir = getDir _x; // Get the facing direction of the sign // Log sign direction for debugging diag_log format ["Sign Direction: %1", _signDir]; private _distanceToSign = _vehicle distance _signPos; private _directionToSign = _vehiclePos getDir _signPos; // Check if the sign is in front of the vehicle and within a certain distance if (_distanceToSign < _detectionRange && abs(_vehicleDir - _directionToSign) < 45) then { // Check if the sign is facing the vehicle if (abs((_signDir - 180) - _vehicleDir) < 45) then { // Additional checks can be added here to ensure the sign is for the vehicle's lane true }; }; }; } forEach _nearbyObjects; // If no sign is detected, return false false }; Share this post Link to post Share on other sites