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
0
Question by magnusm · Jul 31, 2013 at 12:07 PM · javascriptcollisioncollidercustomization

Generating A Custom Collider For Multiple Meshes - Script

Hi :) This might be quite hard for me to explain, so bare with me.

First I will try to explain what I have got going on in my project. I have a ship parent called 'Player' which has a ridigbody on it and can be controlled by a constant force. The player can customize the ship by adding square modules to it, which have the prefix 'Mod_'. These modules are in a group called 'Modules' that is a child of the 'Player', so that they can be controlled by the constant force as well.

This picture is after the ship has been customized, notice the individual modules: alt text

I wish for these modules to have colliders on them, so the ship can bump into things etc. I have tried putting box colliders on each individual module. This works in terms of colliding with things. But it seems to interfere with the ridigbody, and how the ship moves around. It makes it much slower and more unpredictable when more than 1 collider is applied to the ship. I think this is because the colliders on each modules are hitting each other, effecting the movement of the ship. I have tried making it so the modules cannot collide with each other on the collision matrix, but that made no difference.

Its seems the only solution would be to have 1 collider for the whole ship, that works out what the overall mesh looks like and generates one around it.

Is this possible to do? As I know you can use mesh colliders for a single mesh, but can you do it so it generates one to go around multiple meshes within a parent?

Also if you have any other ideas on a solution that would be great!

Thanks for your time reading this hefty passage of text. If you are struggling to understand what I am talking about, just say and I will try to explain further :P

modules.jpg (475.6 kB)
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
Best Answer

Answer by roojerry · Jul 31, 2013 at 02:32 PM

I would assume you would be able to CombineMeshes and add a mesh collider to the resulting mesh.

Comment
Add comment · Show 2 · 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 magnusm · Jul 31, 2013 at 02:35 PM 0
Share

Aah-ha, I was just looking at that now. Combine$$anonymous$$eshes sounds perfecto :P I'll try to give it a go

avatar image magnusm · Jul 31, 2013 at 06:31 PM 0
Share

Unity has a perfect 'Combine Children' script that comes with it, and that combines the meshes like I wanted.

However that didn't fix my original problem with the colliders effecting the movement ridigbody.

I found setting the inertiaTensor manually did, eg: rigidbody.inertiaTensor = Vector3(0.5, 0.5, 0.5);

avatar image
0

Answer by ragnaros100 · Jul 31, 2013 at 02:29 PM

I know you can create a custom mesh and use the information from the 3d model to generate a collider with the mesh collider component. But that'll only work for static models that cant get customized... I'm no code wizard so I don't know how you can procedurally generate colliders

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 magnusm · Jul 31, 2013 at 02:32 PM 0
Share

Yeah that what I realised as aswell. I wonder if there is a way to merge all the individual modules into a single mesh, so that a collider can be generated based of that.

Sounds like something that could be possible :P

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

17 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

Related Questions

Destroy On Collision will not work with spawned AI 1 Answer

Trigger Enter and Exit not working properly? 2 Answers

Can someone help me fix my Javascript for Flickering Light? 6 Answers

Setting Scroll View Width GUILayout 1 Answer

How to make collision check if other collider has component 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