Hello im new to unity and im learning raycast right now , after checking the documentation here https://docs.unity3d.com/ScriptReference/RaycastHit-triangleIndex.html , i got something that's confusing me , what is the difference between :
MeshCollider themeshhit = thehit.collider as MeshCollider;
//
if (themeshhit == null) {
Debug.Log (" | themeshhit == null ! | ");
}
//
and :
MeshCollider themeshhittwo = thehit.collider.gameObject.GetComponent<MeshCollider> ();
//
if (themeshhittwo == null) {
Debug.Log (" | themeshhittwo == null ! | ");
}
//
Both method is working correctly , but i want to know what is the difference between them , and i also want to know which one is better if comparing against speed , compatibility , and ability .
Edit : variable thehit is look similar to this
RaycastHit thehit;