- Home /
Position inside or outside of custom shape (select object if inside custom drawn selection)
Hi gang!
I am using touch and drawing a line which follows my finger in an RTS-like mobile game. When drawing a custom shape (mostly an ellipse/circle-like selection, but could be more random) I store all my points in a Vector3 list.
I've been trying to figure out what the best way would be to determine if a unit is within or without the selection. One option is the point in polygon approach (http://en.wikipedia.org/wiki/Point_in_polygon) however I am not sure how to check if a ray intersects with a mesh edge or another ray.
Alternatively I thought about constructing a mesh from my points and shooting a Vector3.up from my object to see if it's within the shape, but I'm at a loss at how to generate such a mesh when the shape might be quite whacky.
I've usually got too many points, several objects, and the shape could be too complex to make a point by point location comparison.
Any nudge in the right direction is most appreciated. Thanks!
Vlad
Example:
Your answer
Follow this Question
Related Questions
Receiving String from Variable in other Object 3 Answers
determine nearest y outside of mesh from point.y inside 1 Answer
Gun should point at mouse position 3 Answers
Unity Android Movement Problem 0 Answers
2D sprites - Can I use point filtering without getting the "rippling" effect when the camera moves? 2 Answers