- Home /
Question by
isaacduncan02 · Oct 09, 2018 at 01:45 PM ·
raycastscript.collidersphysics2d
colliders vs raycast vs physics.overlap?
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?
Comment