Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 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
0
Question by tonsoflaz · Jun 11, 2013 at 04:49 AM · raycastraycasthitunity remotetexturecoord

Why does my Mesh Collider RayCastHit only return a texturecoord on Unity Remote?

I have searched the answers here for someone with this problem, but I have been unable to find anyone facing the same issue. I have no idea why what I am doing works on Unity Remote but when I compile to iOS stops working.

Basically I am trying to do a simple "touch the screen to make a mark on the object" through editing the UV at the right coordinates. My plan was to do a raycast, then use textureCoord of the RayCastHit to modify the texture at the right place. That plan works fine when I test with Unity Remote.

Here is my code, first on the camera and then on the object:

 // Camera code, to capture screen touches
     function Update () {
            for (var i = 0; i < Input.touchCount; ++i) {
                     var hit : RaycastHit;
                     var ray = camera.ScreenPointToRay (Input.GetTouch(i).position);
                     if (Physics.Raycast (ray,hit, 100)) {
                         hit.transform.gameObject.SendMessage("objectTouched", hit);
                       }
                }
     }

And on the object:

 public void objectTouched(RaycastHit hit) {
             Vector2 texturepos = hit.textureCoord;
     }

Now this code works fine and dandy and gets the correct texture UV coordinates when I am using Unity Remote. I can also do a Debug.Log to ensure that hit.collider is indeed a Mesh Collider. However, when I compile and run it live, all I get for hit.textureCoord is Vector2(0,0), and for hit.collider I get null.

Why would these work fine using Unity Remote, but return null and zero values when run on the actual device?

Thank you in advance.

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

0 Replies

· Add your reply
  • Sort: 

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

14 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

Related Questions

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

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

Sphercast hitinfo TextureCoord rounded? 1 Answer

RaycastHit always returns 0 1 Answer

C# raycast shooting script broken 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