celludriel 79 Posted February 11, 2017 Hey, I'm trying to write some code where I check if a player can see another object. It works for other persons but I just can't get it going for any kind of vehicle. Consider following code: _true_side = getNumber (configfile >> "CfgVehicles" >> typeOf (crew _x select 0) >> "side"); diag_log format ["_x %1", _x]; diag_log format ["_x isKindOf %1", (typeOf _x)]; diag_log format ["_x is tank %1", (_x isKindOf "tank")]; diag_log format ["_x is car %1", (_x isKindOf "car")]; diag_log format ["_player_side %1", _player_side]; diag_log format ["_true_side %1", _true_side]; _visibility = [objNull, "VIEW"] checkVisibility [eyePos player, getPosASL _x]; diag_log format ["visibility %1", _visibility]; diag_log format ["side check %1", (_true_side != _player_side )]; diag_log format ["visibility check %1", (_visibility > 0.5)]; if ((_true_side != _player_side ) && ([objNull, "VIEW"] checkVisibility [eyePos player, getPosASL _x] > 0.5)) then { diag_log format ["visibility check passed"]; Where _x is the object I'm trying to determine I can see, I get following output 17:42:53 "_x O Alpha 1-3:4 REMOTE" 17:42:53 "_x isKindOf O_APC_Tracked_02_cannon_F" 17:42:53 "_x is tank true" 17:42:53 "_x is car false" 17:42:53 "_player_side 1" 17:42:53 "_true_side 0" 17:42:53 "visibility 0" 17:42:53 "side check true" 17:42:53 "visibility check false" I tried _visibility = [objNull, "VIEW"] checkVisibility [eyePos player, eyePos _x]; as well btw. There is something wrong with my determination of the second position, I just can't get a handle on it. I could try and check for the driver in the tank and that eyePos maybe. Seems annoying I would have to do that though. Any insights on the matter ? Thanks in advance Share this post Link to post Share on other sites
bad benson 1733 Posted February 11, 2017 yea i think eyepos might be your issue. this is just speculation but i always thoguht there as a reason why this wiki page makes a difference between eyepos and aimpos. https://community.bistudio.com/wiki/lineIntersects have you tried just using the model center? AtlToAsl(_veh modeltoworld [0,0,0]) AtlToAsl(_veh modeltoworld [0,0,0]) eyepos might be in weird places anyways, who knows. i guess you could then have it be not visible eventhough it's sticking out behind a corner but that doesn't seem to concern you so far. if it does however you could check all the boundingbox corner positions one after another and declare it visible, if one of them is true. Share this post Link to post Share on other sites
celludriel 79 Posted February 11, 2017 Well I got it to work, it has to do with the eyePos, doesn't work on vehicles so I just took the crewman then. _true_side = getNumber (configfile >> "CfgVehicles" >> typeOf (crew _x select 0) >> "side"); diag_log format ["_x %1", _x]; diag_log format ["_x isKindOf %1", (typeOf _x)]; diag_log format ["_x is tank %1", (_x isKindOf "tank")]; diag_log format ["_x is car %1", (_x isKindOf "car")]; diag_log format ["_player_side %1", _player_side]; diag_log format ["_true_side %1", _true_side]; _visibility = [objNull, "VIEW"] checkVisibility [eyePos player, eyePos (crew _x select 0)]; diag_log format ["visibility %1", _visibility]; diag_log format ["side check %1", (_true_side != _player_side )]; diag_log format ["visibility check %1", (_visibility > 0.5)]; if ((_true_side != _player_side ) && ([objNull, "VIEW"] checkVisibility [eyePos player, eyePos (crew _x select 0)] > 0.5)) then { diag_log format ["visibility check passed"]; 18:22:11 "_x O Alpha 1-2:4 REMOTE" 18:22:11 "_x isKindOf O_APC_Tracked_02_cannon_F" 18:22:11 "_x is tank true" 18:22:11 "_x is car false" 18:22:11 "_player_side 1" 18:22:11 "_true_side 0" 18:22:11 "visibility 0.943971" 18:22:11 "side check true" 18:22:11 "visibility check true" 18:22:11 "visibility check passed" It still works with infantry as well, I double checked it but still this was a doozy to figure out. The AtlToAsl would work to but is more expensive, and this code is running on each frame. It's supposed to show tactical icons on top of objects heads, if you are in posession of a sat uplink device. So I need to use the most efficient methods in this script. 2 Share this post Link to post Share on other sites
Tankbuster 1747 Posted February 11, 2017 Yes, I screwed up forgetting to convert it to ASL. Was getting all kinds of crazy result until I remembered. 1 Share this post Link to post Share on other sites
killzone_kid 1333 Posted February 11, 2017 2 hours ago, celludriel said: The AtlToAsl would work to but is more expensive You should not concern yourself with the speed of these converters they are lightning fast 2 Share this post Link to post Share on other sites
celludriel 79 Posted February 11, 2017 Ok I'll keep that in mind for the future thnx Share this post Link to post Share on other sites