- Home /
Rotate Camera To a Specific Pixel ?
Hi...
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 ....
Answer by Timo326 · Feb 06, 2018 at 06:53 PM
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.
Your answer
Follow this Question
Related Questions
Rotated Pixel Textures 1 Answer
Get pixel from Rotated Texture2D 1 Answer
Camera rotation around player while following. 6 Answers
Scripting control of rotation on collision exit of terrain 2 Answers