chartier 1 Posted March 1, 2002 Hi! I'm working on a script that finds a closest vehicle for AI player to board but I'm not able to get nearestObject method to work. All it returns is a <NULL-object> no matter what object "type" I try. I don't want to compare every existing vehicle distance because there are a LOT of them in my mission. Any ideas how to make my script to work? Script: _user = _this select 0 _nearestVeh = nearestObject [_user,"LandVehicle"] _user move getPos _nearestVeh _user assignAsDriver _nearestVeh [_user] orderGetIn true BTW, I'm using OFP version 1.42. Share this post Link to post Share on other sites
SCLZ 0 Posted March 1, 2002 Hmm...I had a quick go at trying to get the thing work. I don't think it was designed for what you intend to use it, I could only get it to return a vehicle of a specific type (i.e not 'all', 'land' or 'landvehicle' only 'Jeep' etc) and only when the vehicle was pretty close to the player. I could get it to choose between two Jeeps but the distance from the player before it stopped working means it wouldn't be practical for what you're looking for. I've only used nearestObject once in a mission and that was to turn a lamppost off, hopefully someone smarter than me will have an answer for you Share this post Link to post Share on other sites
chartier 1 Posted March 3, 2002 Thanks SCLZ! You are probably right about nearestObject so I did the script old-fashioned way: - Created a "Civilian present" -trigger (radius several thousand meters) and on activation listing all the units that would activate it. Empty vehicles are type "Civilian". - Passed the vehicle array and AI unit to the script. - Manually compared each object distance in script. I did a "canMove" check for each object in array to be sure only vehicles are taken into account but I don't know if this is really needed... Share this post Link to post Share on other sites