jcae2798 132 Posted February 8, 2015 (edited) Ok so I need some guidance when getting multiple units/objects. Below is the code i am using: waitUntil {{((_x distance _spawnPos))} foreach allUnitsUAV OR allunits < _spawnDistance}; But i need a way to see if either a UAV or unit is detected to spawn the objects. I tried a few different combos without luck. some failed examples: foreach ((allUnitsUAV) OR (allunits)) foreach allUnitsUAV + allunsit (no errors but didnt spawn on UAV, only unit) Thanks guys. Searching didnt help me ---------- Post added at 20:26 ---------- Previous post was at 20:18 ---------- Sorry i should clarify i am looking to do UNIT OR UAV, not "+" Thanks Edited February 8, 2015 by JCae2798 Edit Title Share this post Link to post Share on other sites
jcae2798 132 Posted February 11, 2015 Any takers? It's for a mission I've designed about to release a public beta on. This would be helpful as the mission relies on reconning the areas with UAVs possibly. Can't get the objects to spawn with UAV, only with player. Or i can use "allUnitsUAV" But then it won't spawn on player. I am looking to do either of the two. Thanks again. Share this post Link to post Share on other sites
jshock 513 Posted February 11, 2015 (edited) If this is MP I would recommend using playableUnits instead of allUnits, just to lighten the load a bit, I made a couple changes for both optimization and maybe to make it work, we will see I guess :p: waitUntil {{(_x distanceSqr _spawnPosition) < _spawnDistance} count (allUnitsUAV + playableUnits) > 0}; Edited February 11, 2015 by JShock Share this post Link to post Share on other sites
fight9 14 Posted February 11, 2015 (edited) this should work [color="#FF8040"][color="#1874CD"]_spawnPos[/color] [color="#8B3E2F"][b]=[/b][/color] [color="#191970"][b]getMarkerPos[/b][/color] [color="#7A7A7A"]"objective"[/color][color="#8B3E2F"][b];[/b][/color] [color="#006400"][i]// position array[/i][/color] [color="#1874CD"]_spawnDistance[/color] [color="#8B3E2F"][b]=[/b][/color] [color="#FF0000"]150[/color][color="#8B3E2F"][b];[/b][/color] [color="#006400"][i]// distance in meters[/i][/color] [color="#1874CD"]_list[/color] [color="#8B3E2F"][b]=[/b][/color] [color="#191970"][b]allUnits[/b][/color] [color="#8B3E2F"][b]+[/b][/color] [color="#191970"][b]allUnitsUAV[/b][/color][color="#8B3E2F"][b];[/b][/color] [color="#006400"][i]// array of objects[/i][/color] [color="#191970"][b]waitUntil[/b][/color] [color="#8B3E2F"][b]{[/b][/color] [color="#8B3E2F"][b]{[/b][/color][color="#8B3E2F"][b]([/b][/color][color="#000000"]_x[/color] [color="#191970"][b]distance[/b][/color] [color="#1874CD"]_spawnPos[/color][color="#8B3E2F"][b])[/b][/color] [color="#8B3E2F"][b]<[/b][/color] [color="#1874CD"]_spawnDistance[/color][color="#8B3E2F"][b]}[/b][/color] [color="#191970"][b]count[/b][/color] [color="#1874CD"]_list[/color] [color="#8B3E2F"][b]>[/b][/color] [color="#FF0000"]0[/color] [color="#8B3E2F"][b]}[/b][/color][color="#8B3E2F"][b];[/b][/color] [color="#191970"][b]hint[/b][/color] [color="#7A7A7A"]"within distance"[/color][color="#8B3E2F"][b];[/b][/color][/color] Made with KK's SQF to BBCode Converter EDIT: JShock beat me to it.... but his doesn't account for the distance to position Edited February 11, 2015 by Fight9 Share this post Link to post Share on other sites
jshock 513 Posted February 11, 2015 but his doesn't account for the distance to position Ah but it does, since I read your post and saw my mistake (edited above), lol, quite fun writing over the changes every time :D. Share this post Link to post Share on other sites
fight9 14 Posted February 11, 2015 (edited) Ah but it does, since I read your post and saw my mistake (edited above), lol, quite fun writing over the changes every time :D. I need to remember to refresh the page before I post. I read the post, go play in notepad, and come back 10 minutes later and post... only to find some one posted the same thing a few minutes prior. lol ---------- Post added at 04:55 ---------- Previous post was at 04:42 ---------- One note, however, with using distanceSqr. You need to to get the square root of it unless you square _spawnDistance also. _distance = sqrt (_pos1 distanceSqr _pos2); Edited February 11, 2015 by Fight9 Share this post Link to post Share on other sites
jshock 513 Posted February 11, 2015 Good point, just wasn't thinking, just remembered from somewhere that distanceSqr was faster, and just did some performance tests and the difference is so minuscule, it probably doesn't matter too much (talking .001ms and .0001ms differences, varies because I'm using the debug console so the code is in a scheduled environment). Share this post Link to post Share on other sites
jcae2798 132 Posted February 12, 2015 Hey guys, thanks! WOrked. I couldnt use the Playable units for whatever reason, but this is a SP mission so hopefully not a big deal. Plus their spawned within distance so hopefully that helps. Anyways i released a beta of the mission i've been working on. Feel free to check it out. Thanks http://forums.bistudio.com/showthread.php?188758-SP-Operation-Eager-Glacier-%28BETA%29&p=2879079#post2879079 Share this post Link to post Share on other sites
jshock 513 Posted February 12, 2015 Try (playableUnits + switchableUnits + allUnitsUAV) for SP. Share this post Link to post Share on other sites
jcae2798 132 Posted February 12, 2015 Ahh, Switchable will probably work! I'll give it a go. Thanks JShock Share this post Link to post Share on other sites