Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
2
Question by Caiuse · Mar 15, 2011 at 03:10 PM · collidercombinelinkhitbox

Combining two hit box (colliders) to become one

alt text

Looking for the best way to combine two hit boxes into one (on collision) creating link between the two objects.

Any Suggestions? Thanks - C

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 Ashkan_gc · Mar 15, 2011 at 03:13 PM 0
Share

do you want to combine two meshes or coliders? just a movement/rotation link? (parent one of them to the other if yes.)

avatar image Firedan1176 · Aug 21, 2015 at 02:11 AM 0
Share

Please accept an answer, or mark answers as not helpful.

3 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by Firedan1176 · Jun 06, 2015 at 01:24 AM

Once the two collide, you can use Physics.IgnoreCollision(object1.Collider, object2.Collider), which will prevent them from colliding. Once the area in either is greater than ~70%, you could destroy one of them, then lerp the size of the new one to be as big as both combined.

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 Statement · Mar 15, 2011 at 03:33 PM

If your objects both have rigidbodies, then I guess you'd need to remove one of them upon collision. Next you should parent the object which rigidbody was removed to the one with the rigidbody still on. Note that the resulting combined collider will remain the same shape of the two separate ones, it won't build a "big collider" as in your drawing with your circles.

Some naive code would look like this but this won't work since you'd get the same callback on both objects. You need to take into consideration the rules for which of the rigid bodies that should be the parent. It only serves as a guide how you could go on with the actual parenting:

// Warning, this code won't work without extra checks!
void OnCollisionEnter(Collision collision)
{
    Destroy(collision.rigidbody);
    collision.transform.parent = transform;
}
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 efge · Mar 15, 2011 at 03:49 PM

Another way to get one new object could be something like this:

Create a new empty GameObject in the center of the hit boxes.
Attach a Rigidbody and Collider to the new object.
Use Collider.bounds to calculate the size for the new Collider.
Use Rigidbody.mass to calculate the mass for the new Rigidbody.
Remove the Rigidbodies and Colliders to the old objects.

(You could also compare the masses of the old objects to adjust Rigidbody.centerOfMass for the new Rigidbody.)

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

1 Person is following this question.

avatar image

Related Questions

creating active objects or spots otherwise said HotSpots 1 Answer

How to combine sprites and make 1 collider for them 1 Answer

Is it possible to detect which side of a sprite a touch came in from? 0 Answers

My Raycast Won't Fire 1 Answer

Fastest way to add calculate damage on different body areas (hit boxes) 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