Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Get the "mesh" of a MeshCollider

Discussion in 'Scripting' started by BoltActionBalrog, May 17, 2016.

  1. BoltActionBalrog

    BoltActionBalrog

    Joined:
    Apr 19, 2015
    Posts:
    2
    Pretty straightforward question, I'd like to know how to retrieve the vertices that compose the mesh of a MeshCollider. I already have code to get the vertices of a mesh object and by extension have no trouble getting the vertices of the visible mesh that the collider is supposed to surround, however the collider and the visible mesh are not guaranteed to be identical. Is there any way to get the actual Mesh object of the shape of the collider itself? Thanks!
     
  2. jaasso

    jaasso

    Joined:
    Jun 19, 2013
    Posts:
    64
    GetComponent<MeshCollider>().sharedMesh.vertices
     
  3. BoltActionBalrog

    BoltActionBalrog

    Joined:
    Apr 19, 2015
    Posts:
    2
    Heh, I misread that to be the underlying imitated visual mesh. Thanks.