- Home /
Sniper Zoom!!!
Hello i was just wondering if anybody could tell me this...
i created a sniper i have done the zoom in animation where it goes to your eye but then i dont no how to make it so it blacks out the screen but has the sniper crossair on the hole of the screen.. if anybody could help me that would be great
Thanks benjimazza.
Answer by aldonaletto · Oct 31, 2011 at 07:49 PM
I answered a question some time ago about this matter, and showed how to use a second camera to make the scope image. Click here to read the answer.
EDITED: If I understood what you want to do, you should create the image (a big rectangular black texture with a transparent hole and the crosshair in the middle) in Photoshop (or other editor) and draw it with OnGUI.DrawTexture. You should also change the FOV (Field of View) to a small number when in scope mode to zoom the image, then restore it when returning to the normal mode:
var scope:Texture2D; // psd or png image with transparency var scopeMode:boolean = false; // set this true to turn scope mode on var zoomFov: float = 10; // zoomed FOV var normalFov: float = 60; // normal FOV
private var rect: Rect;
function Start(){ normalFov = Camera.main.fieldOfView; rect.x = (Screen.width - scope.width)/2; rect.y = (Screen.height - scope.height)/2; rect.width = scope.width; rect.height = scope.height; }
function OnGUI(){ if (scopeMode){ GUI.DrawTexture(rect, scope) Camera.main.fieldOfView = zoomFov; } else { Camera.main.fieldOfView = normalFov; } }
I edited my answer to show a way to do what I think you want. Hope this can help.
Your answer
Follow this Question
Related Questions
Animation stoping!! 1 Answer
Collider Animation 1 Answer
Animation Help!!!!! 1 Answer
Camera Pan 1 Answer
How to play an animation on button press only in trigger stay? 1 Answer