• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
This question was closed May 09, 2014 at 03:44 AM by robertbu for the following reason:

Multiple technical questions

avatar image
Question by _Bidi_ · May 09, 2014 at 03:17 AM · collisioncolliderlinerenderer

Create a collider for area created by mouse

Hi all, sorry for my poor English, I want to create a game like this

alt text

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!

require.png (10.2 kB)
Comment

People who like this

0 Show 3
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image robertbu · May 09, 2014 at 03:43 AM 0
Share

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.

avatar image _Bidi_ · May 09, 2014 at 05:07 AM 0
Share

Thanks for your comment, but now I've drawn path, auto close the path if it not closed. My 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.

avatar image urooj_fatima · Jan 08 at 07:24 PM 0
Share

Are you using a line renderer? If so while adding points to the line rendered you need to add them in the edge collider too. I can show you a similar script to mine.

0 Replies

  • Sort: 

Update about the future of Unity Answers

Unity Answers content will be migrated to a new Community platform and we are aiming to launch a public beta later in June. Please note, we are aiming to set Unity Answers to read-only mode on the 31st of May in order to prepare for the final data migration.

For more information, please read our full announcement.

Follow this Question

Answers Answers and Comments

21 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Detect collider when same object contains more than on collider 1 Answer

How can i create a character like dragon hill game, Digging underground, what collider should i use? 0 Answers

2D:I have a movementController script on my character but it doesn't move forward 0 Answers

There is a slight problem about collider. Lets give a hand pls :) 1 Answer

Line Collision Detection for 2D Game 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges