Touching an object with your finger?

Hello. Rather than touching a button on an iOS device, how can I detect when the player touches an object? My idea was to not mess with any Z axis coordinates, just the X/Y. Say an object is centered at the position of (3,4,5)…how can I detect when the player touches (3,4)?
I hope that made sense. Thanks

How you do this depends on whether you want to deal with physics objects or not.

If you don’t mind adding colliders to the scene, you can put box colliders around buttons or objects in the scene. Then, when you detect a touch, use Camera.main.ScreenPointToRay(…) to transform the touch position into a ray shooting into the scene. Then, use that ray with Physics.Raycast(…) to see if the ray hits any colliders in the scene. If it does, you can access the object it hit with the RaycastHit that it returns.

If you would rather not use colliders, you’ll need to keep track of the locations/sizes of your objects and then calculate whether their bounds intersect a set of bounds around your touch position (there are probably many methods to do this). Suffice to say, the collider option is more straightforward.