Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • 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 /
avatar image
0
Question by theorbzone · Oct 09, 2018 at 01:52 AM · 2dnoobmeshespolygons

Need help with creating a 2D polygon from a series of GameObjects in C#

Hi! I'm making a puzzle game about catching rain (circles) from the sky, and clicking the water to turn it into ice (a polygon). The only problem is that I'm a complete noob when it comes to programming with Unity and I only have a very basic understanding of it. I have absolutely no idea how to turn a whole bunch of GameObjects into a solid polygon and need help!! How can I make a script that turns a group of circles into 1 solid object with a click?

Comment
Add comment · Show 2
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 Casiell · Oct 09, 2018 at 08:20 AM 1
Share

Do you want to change shape of those objects? Or you simply want to group them into one entity that looks exactly the same as those objects separated, but moves and rotates as one object?

avatar image theorbzone Casiell · Oct 10, 2018 at 02:39 AM 0
Share

Yeah the second one, just group them together into an object that can be rotated and has collision!

3 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by rbeldessi · Oct 10, 2018 at 05:35 AM

If you just want to group them together you simply have to generate a new GameObject and then set the parent of each rain drops transform.

 GameObject newParent = new GameObject ();
 foreach(transform t in raindrops)
     t.parent = newParent.transform;

Where raindrops is an array of the transforms of each raindrop. Edit: I misunderstood the question. Completely different answer than the original.

Comment
Add comment · Share
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
1

Answer by Casiell · Oct 10, 2018 at 06:52 AM

@rbeldessi answer is actually correct. When you parent all your objects to one game objects, you can then treat that parent as your main object. What you may want to do is, after parenting remove all Rigidbodies from your little objects and add a rigidbody to the parent. Colliders on children objects are ok, they will work normally and they will raise events you can catch in parent scripts.

Comment
Add comment · Share
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
0

Answer by theorbzone · Oct 10, 2018 at 07:33 AM

The other biggest challenge I can't wrap my head around is that when you click on 1 drop it should also affect all drops it's connected to. Though thanks a lot for helping to answer!!!

Comment
Add comment · Show 4 · Share
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 Casiell · Oct 10, 2018 at 08:03 PM 1
Share

So put a script on the parent object. $$anonymous$$eep a reference of all the drops that it's responsible for and do all the logic from the parent object. The parent should receive all mouse click events that would happen to any of it's child

avatar image theorbzone Casiell · Oct 10, 2018 at 08:24 PM 0
Share

GENIUS!!!!!

avatar image theorbzone Casiell · Oct 10, 2018 at 08:42 PM 0
Share

Thank you, that helps alot! But i still need to figure out how to tell when a raindrop is colliding with other raindrops :(

I'm so close to figuring this out i can taste it!!!!!

avatar image Casiell theorbzone · Oct 10, 2018 at 10:07 PM 1
Share

If a moment of the collision is enough you can use OnCollisionEnter2D.

If you need to know if two objects are colliding at any given moment you could use OverlapCollider or GetContacts.

I've never really used the last two, so I can't offer much help, but one of those three methods should give you what you want

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

189 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 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 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 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 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 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 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 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 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

(noob) 2D sprite jagged edges as smaller? 1 Answer

Generate Polygons and Colliders Runtime in 2D Game 0 Answers

How to keep and grow a polygonal area in 2D 3 Answers

Assets/Scripts/PlayerController.cs(32,49): error CS0126: An object of a type convertible to `float' is required for the return statement 1 Answer

How to render polygons in unity? 0 Answers


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