Item pickup, OnTrigger vs Raycast? Which is best?

Does it matter which you use? Is one more optimized for this behavior?

The two methods give different end results, so use whichever gives the effect you like.

Triggers will work even if you back into it with someone else in-between. A rayCast would make sure you can see it (for example, it’s next to a wall and you can’t grab it “through the wall”) and might be an easy way to make sure you are “looking” at it.

I’ve tried this using Raycast and Physics.OverlapSphere and OverlapSphere was vastly faster. Once I started having 100’s of items the Raycast eventually would cause a large spike in my fps on the Profiler and the game would studder. After switching to Physics.OverlapSphere the spike was gone.