Rotate Camera To a Specific Pixel ?


How can I rotate my Main Camera to a specific pixel on a (Quad or Plane) object.

for Example :
I’ve an image 1024*768
I want, when I press on first button , camera rotate to pixel ( 300x * 400y ) and when I press on second button, camera rotate to pixel ( 900x * 250y)

Thank you …

When Vector3 pivot is the lower left corner of your plane, then you can calculate the Vector3 targetPoint in this way:

targetPoint = pivot + plane.transform.right * plane.transform.localScale.x * (300/1024) + plane.transform.up × plane.transform.localScale.y * (400/768);

Then you can use the transform.lookAt of your camera.

The code above may have mistakes. I am currently not able to test it.