- Home /
Multiple technical questions
Create a collider for area created by mouse
Hi all, sorry for my poor English, I want to create a game like this
For example, the requirement is 2 red balls and 2 yellow balls, then the user uses mouse to draw a shape in order to meet the requirement.
My logic is create a collider covered by the drawn line and check the collision with the balls. But I dont know how to make that. I've learn Unity for 1 weeks, please help ^^ All comments is much appreciated. Thanks!
Unity Answers addresses questions with a single specific issue. Unity Forums is a better fit for high-level design questions like yours.
You have a number of individual technical problems:
How to draw a line
How to save a path
How to detect when a path is closed
How to detect what balls are inside the path
In turn each one of the above has a number of technical issues/decisions. Addressing the specific question of building a collider, you can build a mesh using an arbitrary path using this script from the Unity Wiki.
http://wiki.unity3d.com/index.php/Triangulator
A better solution to run through the line segments comparing all balls to each segment. For a ball to be inside the path, the ball must be on the same side of all line segments.
Thanks for your comment, but now I've drawn path, auto close the path if it not closed. $$anonymous$$y problem now is detect how many balls inside and I think I can check by the collision. However, I dont know how to do that. How to create the collision for the area that created by the closed path. That is my question. Thanks for your consideration.
Follow this Question
Related Questions
Line Collision Detection for 2D Game 1 Answer
Player Object can hang on the collider forever 0 Answers
Detect collider when same object contains more than on collider 1 Answer
2D:I have a movementController script on my character but it doesn't move forward 0 Answers
How can i create a character like dragon hill game, Digging underground, what collider should i use? 0 Answers