Search Unity

MouseInput Detecting Mesh of GameObject

Discussion in 'Physics' started by jttarigan, Oct 5, 2019.

  1. jttarigan

    jttarigan

    Joined:
    Mar 13, 2018
    Posts:
    2
    Hi, newb here,

    I am currently trying to detect mouse input and find which triangle (of a gameObject) that hit. I know how to detect which gameobject is hit, but is it possible to detect which triangle (of the gameobject) is hit? A few google search gave me a solution is to loop through all the vertex and find the closest one to the hit point. But it seems excessive since each gameobject consists of a lot of vertices.

    My object is a wide plane with random height (currently building my own terrain editor) and the plane consists of multiple gameobject with multiple triangles. Any idea?

    Thanks.