Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 Kiefy · Jan 02, 2017 at 09:31 AM · raycasthittexturecoord

RaycastHit.textureCoord is broken?

Can anyone please confirm if RaycastHit.textureCoord is actually working? No matter what I do it always returns 0,0. I have a Convex MeshCollider on a UV'd cube mesh.

I even recreated the basic example from the docs RaycastHit-textureCoord and that doesn't work either.

Via debugging, I have determined that the raycast is hitting the correct object, and returns the correct texture name.

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
5
Best Answer

Answer by Bunny83 · Jan 02, 2017 at 09:48 PM

It does work, but not with a convex mesh collider. It only works with a normal mesh collider. If you check "convex", Unity will create a new mesh which will be the convex hull of the original mesh. Therefore the meshcollider has no logical relation to the original mesh and doesn't have texture cordinates at all. The convex mesh usually looks different from the original mesh.

You only need a convex collider if the object is used as rigidbody. If you need both, you can add two colliders, one convex and a normal one. Place them on different layers to control the behaviour / interaction.

I'm not sure i understand what a shader has to do with all that. A collider is a pure logical object that has no relation to rendering. So a collider always works the same, no matter if the object is actually visible.

Reading or writing pixels to a texture requires the texture to be marked as read- / writeable. Textures that are created at runtime are automatically read/writeable.

If you experience problems with changing textures and not seeing any result in the scene might be related to (static) batching. Do not mark an object as static if you change anything on that object. If an object is batched the original renderer becomes useless as the object is now part of a big (batched) mesh.

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 Kiefy · Jan 03, 2017 at 12:04 AM 0
Share

Thank you for the detailed reply.

I figured it out a couple of hours ago, but my answer was awaiting moderation, and now it's disappeared. :S

The issue was indeed due to the Convex option. though I thought that the Generate Colliders option needed to be ticked on model import also, but I guess not.

You deserve the answer. I can't yet though. my own answer must still be locked in limbo & I'm unable to award you it, but I will when chance comes.

Edit: There we go. Thanks again! :)

avatar image
1

Answer by Kiefy · Jan 04, 2017 at 08:47 AM

Ok, I figured it out.

When importing the mesh, you must tick Generate Colliders to add the Mesh Collider, instead of adding one yourself. and make sure Convex is unticked on the Mesh Collider component.

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

Sphercast hitinfo TextureCoord rounded? 1 Answer

Why in Unity3D RaycastHit. textureCoord always return 0,0 after building the project? 1 Answer

RaycastHit Texturecoord doesn't work with separate colliders 0 Answers

RaycastHit.textureCoord ranges from (0,0) to (1,1) for each face. 2 Answers

Get pixel colour on a ray hit 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