Answers for "How can calculate the drawn circle range ?"
http://answers.unity.com/questions/1389864/how-can-calculate-the-drawn-circle-range.html
The latest answers for the question "How can calculate the drawn circle range ?"Answer by Bunny83
http://answers.unity.com/answers/1389875/view.html
Here'
rangeSqr = drawcircle.xradius * 2;
you don't calculate the square of the radius but you multiply it by 2. So a radius of 5 would yield a value of 10 (5*2) instead of 25 (5*5).
Why exactly are you using two different radii for x and z ? If the two are not the same the result would be an ellipse instead of a circle. Many logical deductions won't work with an ellipse that does work with circles.
So you should do:
rangeSqr = drawcircle.xradius * drawcircle.xradius;
Note that you only check the center of the object. So the object is only inside when it's pivot enters the range. If the object is large the actual mesh might already overlap with your range but as long as the center isn't inside the range the object will still be considered outside. A common solution is to give both a circular range. You can simply add the two radii before you square it. This way your condition is only true if the two circles overlap.
ps:
If you want to be able to use an ellipse it gets more complicated as the radius depends on the orientation of the object. If your line renderer uses localspace positions the distance vector need to be transformed into the localspace of your linerenderer. The direction vector would be normalized and each component would be multiplied by the corresponding radius. Then you can calculate the squared length / magnitude of that vector. If both objects may use an ellipse each has to use it's own localspace to get the proper radius vector. Again you can simply add the two radius vectors before you get the square length in order to add their radii.Sun, 06 Aug 2017 03:15:18 GMTBunny83