As simple as it gets:
How to find out which object is under a specific pixel?
For example, something like this:
GameObject ObjectUnderPixel(float x, float y) { // algorithm here }
I’m guessing it has to do with raycasting, but I am not sure how to position the ray.
Thanks
Assuming by ‘pixel’ you mean a screen coordinate, then the code is mainly here: http://unity3d.com/support/documentation/ScriptReference/Physics.Raycast.html?from=Input Note the object must have Collider on it
var ray = Camera.main.ScreenPointToRay (Input.mousePosition); var hit : RaycastHit; if (Physics.Raycast (ray, hit, 100)) { // Debug.DrawLine (ray.origin, hit.point); var objectHit = hit.collider.gameObject; }