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 MichaelTaylor3d · Sep 04, 2013 at 01:31 PM · raycastmeshobject

Detecting the subobject of a mesh

I have a mesh that has over a 3000 separate sub objects. (groups of polygons that dont touch the rest of the object)

As a single mesh, the mesh goes into the scene pretty fast. But the minute I break up each subobject into its own object, the game slows to a crawl.

Normally when you do a raycast, it detects the entire object that it hit. Is it possible to raycast so that it only returns the subobject that it hit?

That way I wouldnt need to break it apart.

Comment
Add comment · 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 · Sep 04, 2013 at 05:13 PM 1
Share

Don't know if you can make this solve your problem, but the RaycastHit structure returns the triangle index for the triangle hit (RaycastHit.triangle). So if you can build a mapping between triangle and 'subobject', then it will work. I did this for hypertext links on one project, but my mesh was built at runtime making it easy to build the mapping. Assu$$anonymous$$g your shader does not need it, you might be able to encode your subobject references in a vertex attribute. You might be able to specify that in your 3D authoring program.

avatar image $$anonymous$$ · Sep 04, 2013 at 05:28 PM 0
Share

AS robertbu suggested I don't think you can see what is a submesh or not, you can either do as above suggested with triagle hit, or you can create different gameobjects with colliders and position them by hand. This if you are not instantiating the meshes at runtime, otherwise will be a pain in the ass.

Alternatively in the next unity update they are gonna add the ability to add multiple colliders per gameObject, you may want to look at that.

avatar image DaveA · Sep 04, 2013 at 07:01 PM 0
Share

This has been asked and answered. I will try to find the thread

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by DaveA · Sep 04, 2013 at 07:08 PM

http://answers.unity3d.com/questions/291853/raycasthit-triangleindex-and-submeshes-which-subme.html

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

18 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

Related Questions

Resizing one mesh to fit another mesh. 0 Answers

What technique for tile-based 2D game 0 Answers

Raycast to align character on MeshCollider normals 1 Answer

Generate mesh from raycast positions, independent of rotations 0 Answers

Mesh gets squashed after parenting to camera. 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