marker 1 Posted March 21, 2013 Hey guys.. Trying to find the nearest landvehicle closest to my position within a heli! I am using nearestobject, tried it with this code _lock = nearestobject [heli, iskindof "LandVehicle"]; I am getting a Error Missing ] in my rpt.. How would I use that within the nearestobject structure? Thanks Share this post Link to post Share on other sites
neokika 62 Posted March 21, 2013 iskindof "LandVehicle" The above throws an error because it is missing the object. player iskindof "Man" The above would return TRUE. Although, the nearestObject function needs only a String, in his case it would be "LandVehicle". _object = nearestObject [heli, "LandVehicle"]; _object is now the nearest "LandVehicle" object, if any is actually near, otherwise will be ObjNull (NULL). Share this post Link to post Share on other sites
marker 1 Posted March 21, 2013 iskindof "LandVehicle" The above throws an error because it is missing the object. player iskindof "Man" The above would return TRUE. Although, the nearestObject function needs only a String, in his case it would be "LandVehicle". _object = nearestObject [heli, "LandVehicle"]; _object is now the nearest "LandVehicle" object, if any is actually near, otherwise will be ObjNull (NULL). Thanks for that mate! One other problem now, hopefully some will be able to do this.. The problem is nearestobject only returns a value within 50 meters, and cannot be changed. I am hoping to use nearestobjects instead, like below. _lock = position heli nearObjects ["landvehicle",500]; Now when I use that, and use hint format ["%1", _lock]; I get the vehicles within that distance returned perfectly! What I want to do is be able to grab the name of the first one located and use that... My code is below.. And works as expected using the two commands.. private ["_camFLIR","_follow","_lock"]; heli = _this select 0; _camFLIR = _this select 2; _camFLIR = heli getvariable "camFlir"; _follow = heli getvariable "FOLLOW"; sleep 0.2; //_lock = nearestobject [heli, "landvehicle"]; _lock = position heli nearObjects ["landvehicle",200]; hint format ["%1", _lock]; if (!isNull _lock) then { player sideChat "Camera Locked"; _follow attachto [_lock,[0,0,0]]; _camFLIR camPrepareFOV 0.3; heli setvariable ["zoom",0.3,true]; _camFLIR camCommit 1; }; As I said in my case just now, it is returning car1, car2. Which is correct, with car 1 being the closest... What would I need to do to have the closest object allocated to _lock or whatever it has to be changed to? Hope that makes sense! Share this post Link to post Share on other sites
f2k sel 164 Posted March 22, 2013 The first in the list should be obj= _lock select 0; Hove you tried nearEntities as it's supposed to be quicker Also is it just me or is everyone having to enter a captcha with every post and search tonight. Share this post Link to post Share on other sites
marker 1 Posted March 22, 2013 The first in the list should be obj= _lock select 0;Hove you tried nearEntities as it's supposed to be quicker Also is it just me or is everyone having to enter a captcha with every post and search tonight. I am as well mate... Thought that might have been my punishment for my infraction :) Had a look and the problem is the same for me, which is.. How would I capture the first vehicle returned... Cheers Sorry didn't see your top comment, too busy deciphering captchas! Share this post Link to post Share on other sites
neokika 62 Posted March 22, 2013 It's better to use nearestObjects instead, it will return the objects from the nearest to distant, while nearObjects won't. //Search for nearest objects _objects = nearestObjects [heli, ["LandVehicle"], 200]; //Have we found any? if (count _objects > 0) then { //The nearest object _object = _objects select 0; }; Share this post Link to post Share on other sites
marker 1 Posted March 22, 2013 Would the use of nearentities not be better as it would find only land vehicles that are alive? Share this post Link to post Share on other sites