Pikey Posted February 6, 2017 Share Posted February 6, 2017 Hi, I can't get unit in moving zone working with spawned or teleported objects as the zone radius to check, it simply doesnt work, so is there a simple way to accomplish the same thing easily? ___________________________________________________________________________ SIMPLE SCENERY SAVING * SIMPLE GROUP SAVING * SIMPLE STATIC SAVING * Link to comment Share on other sites More sharing options...
Grimes Posted February 7, 2017 Share Posted February 7, 2017 Hmm, may need to just do it with just scripting. Frankly I'm surprised any of the trigger conditions still work with units spawned via scripting. Ultimately it is just the Pythagorean theorem. if square root of difference of pointA.x and pointB.x added to the difference of pointA.y and pointB.y is smaller than the radius, then a unit is in zone. While that may look complicated it really isn't that bad. Here is a really simple example in lua: local u1 = Unit.getByName('unit1'):getPositon().p local u2 = Unit.getByName('unit2'):getPositon().p if ((u1.x - u2.x)^2 + (u1.z - u2.z)^2)^0.5 <= 5000 then -- units are within 5000 meters of each other end There is a flagFunc built into mist that sort of mimics the trigger condition to get the same overall result. The right man in the wrong place makes all the difference in the world. Current Projects: Grayflag Server, Scripting Wiki Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread) SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum Link to comment Share on other sites More sharing options...
Pikey Posted February 7, 2017 Author Share Posted February 7, 2017 Thanks. I can't give you any more rep. Hmm, may need to just do it with just scripting. Frankly I'm surprised any of the trigger conditions still work with units spawned via scripting. Ultimately it is just the Pythagorean theorem. if square root of difference of pointA.x and pointB.x added to the difference of pointA.y and pointB.y is smaller than the radius, then a unit is in zone. While that may look complicated it really isn't that bad. Here is a really simple example in lua: local u1 = Unit.getByName('unit1'):getPositon().p local u2 = Unit.getByName('unit2'):getPositon().p if ((u1.x - u2.x)^2 + (u1.z - u2.z)^2)^0.5 <= 5000 then -- units are within 5000 meters of each other end There is a flagFunc built into mist that sort of mimics the trigger condition to get the same overall result. ___________________________________________________________________________ SIMPLE SCENERY SAVING * SIMPLE GROUP SAVING * SIMPLE STATIC SAVING * Link to comment Share on other sites More sharing options...
Recommended Posts