VeTaL Posted July 21, 2010 Share Posted July 21, 2010 I want to make the simplest trigger, which would be triggered as player moved far from center of the map. Which one would be the simplest? 1) calculate by Pythagoras theorem: if (sqrt( sqr (player.x - center.x) + sqr ( player.y - center.y)) > radius) then ... it is perfect for my needs, but i'm looking for more simple solution as this consist of two sqr's and one sqrt. 2) calculate by squares: if ((((player.x - center.x) * ( player.y - center.y)) / 2) > radius) then ... this is lot faster, but not too precious : (player.x - center.x) can be too large, but if ( player.y - center.y) would be too small, object would be still counted as "inside" the radius even if he would be far away. 3) add a physical sphere and trigger event when player wouldn't be inside a sphere any ideas about this? Quote Working on LeaFAQ Link to comment Share on other sites More sharing options...
Canardia Posted July 21, 2010 Share Posted July 21, 2010 EntityDistance(centerpivot,player) Quote ■ Ryzen 9 ■ RX 6800M ■ 16GB ■ XF8 ■ Windows 11 ■ ■ Ultra ■ LE 2.5 ■ 3DWS 5.6 ■ Reaper ■ C/C++ ■ C# ■ Fortran 2008 ■ Story ■ ■ Homepage: https://canardia.com ■ Link to comment Share on other sites More sharing options...
VeTaL Posted July 21, 2010 Author Share Posted July 21, 2010 Well, okay, i hope this is the fastest solution, thanks. Quote Working on LeaFAQ Link to comment Share on other sites More sharing options...
L B Posted July 23, 2010 Share Posted July 23, 2010 I guess EntityDistance does the Pythagorean algorithm anyway. And still, this allows for a low Y value and high X value or vice-versa. The best method for your situation would really be the physical sphere, or a center inequation from the conics formulas. Quote Link to comment Share on other sites More sharing options...
VeTaL Posted July 24, 2010 Author Share Posted July 24, 2010 I think i can use fact, that center of the trigger is map center. So, in another words, i can just check [if ((player.x < radius) && (player.x > -radius) && (player.y < radius) && player.y > -radius))] Looking like it would be the fastest solution, but it would be square, not sircle. Quote Working on LeaFAQ Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.