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
1
Question by swokes · Nov 01, 2013 at 01:43 AM · raycastmeshcollidermeshes

Does RaycastHit.textureCoord assume collider mesh and renderer mesh the same?

Been trying to get to grips with how Raycasting works and something that bothered me was that raycasting works with colliders, not rendered meshes. However the way it seems to be used (for example in the scripting reference) is that it refers to the underlying mesh for rendering, which may not be the same. Its entirely possible to have the mesh for rendering and the mesh for collisions to be completely different (not quite sure why you would do this, but it is possible). What happens in this situation?

I guess that the RaycastHit.textureCoord just returns the UV reference for the collider mesh, as this is the only thing it knows. Then when this the associated script tries to do something intelligent to the rendered mesh it just results in garbage. Am I right? Or have I not understood how this all works?

I would appreciate assistance on clarifying this.

Thanks

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 Bunny83 · Nov 01, 2013 at 02:14 AM

You're absolutely right ;) Only the MeshCollider will actually return textureCoords, all other colliders don't have UVs. Of course the returned coordinates belongs to the collision mesh and has no relation to the visible representation. Keep in mind that a gameobject can only have a collider without any renderer.

By default the MeshCollider uses the same mesh as the MeshRenderer, but you can use different meshes if you like. Of course if you do, the physical representation is different from the visual representation.

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 aldonaletto · Nov 01, 2013 at 02:28 AM

The MeshFilter mesh is assigned to the mesh collider when the latter is created, but after that you may assign a different mesh to the collider at any time, by script or in the Editor. The collider mesh isn't automatically updated too, thus modifying the MeshFilter mesh by script doesn't affect the collider - you must assign the new mesh to collider.sharedMesh in order to update it. Finally, textureCoord only works for mesh colliders - primitive colliders like sphere, cube or capsule set it to Vector2.zero.

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

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

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

How do I change the value of a tag with raycasting? 0 Answers

Disabling a lineRender or Ray when there is no target 1 Answer

RaycastHit Triangle Index Problem 0 Answers

Ignore/Destroy then re-enable Mesh Colliders 3 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