- Home /
Question by
toishaanpatel · Jul 24, 2020 at 05:28 PM ·
c#raycastcollidertransformraycasthit
RaycastHit: What is the difference between hit.transform.tag and hit.collider.tag and which should I use when?
I am trying to make the player shoot a raycast and detect if hit the enemy's sphere collider. What should I use and which would work better? The objects both have tags on them.
Comment
Answer by mbro514 · Jul 25, 2020 at 12:56 AM
I'm pretty certain that both do the same thing, it's just that one accesses the tag via the transform and the other via the collider. As far as I know, there is no difference between them, except that one of them (if I had to guess, hit.transform.tag) might take minimally longer to do.
But you should be fine doing either.