Search Unity

Raycast does not hit mesh collider

Discussion in 'Editor & General Support' started by vegenarie, Sep 7, 2015.

  1. vegenarie

    vegenarie

    Joined:
    Jan 5, 2011
    Posts:
    287
    I am using raycast to hit a mesh collider and it just hit when has active the convex option, which is not useful as i need it without that.
     
    darryldmps likes this.
  2. darryldmps

    darryldmps

    Joined:
    Mar 11, 2015
    Posts:
    6
    I'm also experiencing the same problem. The ray is not detecting a hit on imported planes or meshes that are single sided (other imported meshes are fine). I have tried with different variations on the model import settings, including generate collides. What's strange is collision are detected with these objects, just not the rays hit.

    Using Unity 5.2.0f3
    Maya 2015

    Solution:

    Okay I figured out the problem. It's being caused by the up scaling of the mesh (single sided or a plane). For example, if you have imported a mesh, placed it in the scene, then up scaled it a significant amount, the problem is created. If you delete the mesh from the hierarchy, go back to the imported mesh in the project folder, increase its scale there (in the import settings). Upon placing it back in the scene it should now respond to ray hits.
    Not sure if this is a bug or a known issue, but this seems to solve it.
     
    Last edited: Sep 16, 2015
  3. yogihermawan1993

    yogihermawan1993

    Joined:
    Jun 17, 2014
    Posts:
    1
    What are you trying to import? if it is a terrain generated by sculpting a plane object, then don't use plane. My simple method is using a cube object, delete all its faces except for the top one, subdivide the top face, and begin sculpting. So all terrains i've generated so far has two sides unlike a plane which only has one side (invinsible from the other side). Raycast hit wont cooperate with single sided object.
    Hope this will help.