colliders vs raycast vs physics.overlap?

Updated on October 10, 2018 in [A] Unity Scripting
Share on Facebook0Tweet about this on TwitterShare on Google+0Share on Reddit0
0 on October 10, 2018


From the unity tutorial page, it states raycast are expensive operations that should be refrain from using in update/fixed updated functions. So an optimal example of this would be if a player presses the attack key, and a raycast is cast in front of them to see what enemies he would hit. Whereas colliders are best if an object is constantly checking if it is colliding with something, e.g. if the player is on the ground as they are optimize for that. Since overlap and raycast are from the same physics library am guessing that the conditions used are the same, the only difference being that overlap checks for an area, whereas raycast is just a line.

Is this right to assume and is there anything else to note?

  • Liked by