- Home /
Aiming down a gun
Ive been working on an fps game in unity for a while now and are almost finished but im not sure how to create scopes and be able to look down them if anyone noes please can you help me
Answer by oliver-jones · Nov 24, 2010 at 04:46 PM
Okay, This is what I do:
static var ZoomOut = Vector3(0.265012, -0.1908424, -0.7531716); //Current Position of Gun
static var ZoomIn = Vector3(0.0135, -0.12, -0.8); //Position of Zoom (trial and error)
static var Zoom = false;
function Update () { if(Input.GetButtonDown ("Fire2")) {
transform.localPosition = ZoomIn;
Crosshair.OriginalOn = false;
Camera.main.fieldOfView = 40; //Turn off crosshair
}
if(Input.GetButtonUp ("Fire2"))
{
transform.localPosition = ZoomOut;
Camera.main.fieldOfView = 60; //default = 60
Crosshair.OriginalOn = true;
Zoom = false;
}
}
On to your weapon. So you should have your player controller > main camera > weapon (im guessing) just drag it on to your weapon that you want zoo$$anonymous$$g in.
NOTE: once you have added the script, you will need to change the ZoomOut variables to your current position of your gun
when i copy the script you have given me an error comes up saying original on is not a member of crosshair
Your answer
Follow this Question
Related Questions
Why my game's FPS drop every time I change scene (Android Game) ? 1 Answer
Main Menu Instructions? 2 Answers
multiple animations? 1 Answer
Horror Game AI script recommendation? 1 Answer
FPS Game Level Loader 0 Answers