- Home /
Check if a ball is inside a circle drawn by a line
I'm new with Unity and I need to know how to check if a ball is inside a circle drawn by a line. I keep the collision points of each point of the line in an array to detect if it goes into collision with the ball, and each point of collision has its X - Y points and I need to know if the user has managed to surround the ball with the line that he has drawn.
If you can help me with a little code I would appreciate it.
Thank you.
Answer by LiloE · Mar 06, 2017 at 08:01 AM
Use PolygonCollider2D And OverlapPoint function
Your line game object should have a
PolygonCollider2Don it.Once you detect the circle is complete, change the
pointsof the collider to the X-Y points you have.Use
OverlapPointfunction of the collider to detect if key points on the contour of the ball are inside the line's collider.
Your answer
Follow this Question
Related Questions
Distribute terrain in zones 3 Answers
Multiple Cars not working 1 Answer
Replicating MC Redstone Wiring 3 Answers
how do i keep a gameobject in between the union of 2 or more than 2 circles 0 Answers
Can't teleport on the X axis 2 Answers