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 Wolfone · May 08, 2017 at 01:33 PM · collisiontransformparent-child

How to glue Objects together on contact?

Hello everyone,

i am trying to get my feet wet with Unity and what i want to do is sticking an object to another one on contact, so if one of the objects which are glued together moves, the other moves relatively.

I read some threads and they come up with rather simliar scripts so i tried it this way:

 void OnCollisionEnter(Collision other)
     {
         if (other.gameObject.tag == "Glueable")
         {
                 other.transform.parent = gameObject.transform;
         }
     }

I understand that the effect should be making the hit object a child to the hitting object so they move together. I tested this but the hit object just makes some little funny moves (not relative to the theoretical new parent) before it falls through the floor -.-

Why does that happen? It seems there are aspects that i don't understand. Is it the right method to achieve what i want in the first place.

Any help is appreciated :)

Comment
Add comment
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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by leech54 · May 10, 2017 at 01:24 PM

I am guessing that you have to turn physics of the child off once it sticks to the other or it will keep trying to push the colliders away from each other.

Comment
Add comment · Show 1 · 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 Wolfone · May 13, 2017 at 09:24 AM 0
Share

Ahhhh, ok; i will try that as soon as i got a little bit more time for this. But wouldn't that mean that the child objects would be subject to clipping issues? Sorry for my late reply. I'm a little bit busy right now.

avatar image
0

Answer by Twinklier · Aug 20, 2019 at 12:34 AM

Or u could use a spring joint. It has this springy effect (maybe put a lot of spring value in it) to get the "sticky" feel, like stretching it out and it will snap back like an actual glue-y, slimy thing. You can even put some other value besides Infinity in the break force to simulate the real glue! (You may need to do some scripting or modeling to get the glue-slime effect tho). And just simply use OnCollionEnter to assign the "other" collision to the connected body and voila! I hope this helps :)

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

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

6 People are following this question.

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

Related Questions

Make a GameObject a Child of What it Collides With 2 Answers

Is there a solution to when colliders bypass? 2 Answers

Make AI run from Player 1 Answer

How to move a Game Object from a script not attached to it. 1 Answer

Moving an object away from collider 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