- Home /
set the Camera position on the screen
Hy, I want to set a Camera position on the screen but I have no idee. My idee was: I have a given screen pixel position(ex.:81,81 ) and I tryd to set the Camera.pixelRect.center, but pixelRect is a temporary variable. Than after I tryd to use: Camera.rect = new Rect (...), but I can`t do a convert from screen pixel to Camera normalized View port. Sorry for my bad english;) .Thanks for any helps.
is this the one you look for ?
Documentation/ScriptReference/Camera.ViewportToWorldPoint.html
Answer by Prabir · Oct 22, 2012 at 07:47 AM
Hey i am not an expert but i guess this will works :-
var MyCamera : Camera;
MyCamera.transform.position.x = 81 ;
MyCamera.transform.position.y = 81 ;
You can place this code in the function Update().
In the inspector window , drag your camera object and place in this variable.
Your answer
Follow this Question
Related Questions
Clicking Trigger 1 Answer
Lock the screen 1 Answer
Camera Shake 4 Answers
Mix 4 cameras on screen like chain sequence 0 Answers
How to 2D Camera follow with lag. 1 Answer