collider trigger or scripting

What’s better for performance?

Use a collider with a trigger or use an array and check the distance or something and starts an action?

Raycast will give you more accurate selection of which object you want to trigger an action on. (you can point at an object with a ray and check distance, and get info about the object the ray hits etc…) Triggers would be better for preformance, but won’t give you the same accuracy.

https://unity3d.com/learn/tutorials/modules/beginner/physics/raycasting

If you check only the layers you need in project settings → physics you will get a nice performance. If you make your own script will depend how good programmer you are.

I found the problem. I did all de debugging with the editor. When I use the profiler on the phone the gc alloc disappear. I read on a forum that get component is zero, create gc alloc when the profiling is set on the editor.