gun scope cam not working

I am starting a fps game. I am currently doing the scope part of a m4a1.

I made a cam for the scope called scopecam and a javascript called scope.

here is what it is inside the script:

	var Aim : boolean = false;
	
	var Cam : GameObject;

function Update () {


		if (Input.GetMouseButtonDown(1)) {

			Aim = true;
		
			if (Aim == true) {
		
				Cam.active = true;
		
		
		
			}
		
		if (Input.GetMouseButtonUp(1)) {
	
			Aim = true;
	
			if (Aim) {
	
				Cam.active = false;
				
			}
	
		}
	}
}

I believe that 1 is for the right mouse, isnt it?

after that i have linked the script to the first person controller and the cam to the fp controller too.

I have also dragged the cam to the script where it says - cam: none(gameobject).

everything is ok until when i test the game, the scope is not responding.

thanks for the help!

Make sure that your also disabling the main camera when you scope,
here’s what I did:

var ScopeToggle : boolean = false;
var ScopeCam    : Camera;
var GunCam      : Camera;    //I have a separate camera that renders my guns,
                             //You can set this to the main camera if you want

    if (Input.GetButton("Fire2")){ //Fire2 is the same as rightmouse
        ScopeToggle = true;
        
    }
    
    if (Input.GetButtonUp("Fire2")){
        ScopeToggle = false;
    }
    
    if (ScopeToggle){
        ScopeCam.gameObject.active = true;
        GunCam.gameObject.active = false;
    }
    
    if (!ScopeToggle){
        ScopeCam.gameObject.active = false;
        GunCam.gameObject.active = true;
    }

it is still not working though? i’ve changed the main camera to GunCam, and changed my script to yours and nothing happened when i chick and hold the right mouse.

but thanks for the help

By me the same, it aims the whole time if I select “scope toggle” if I deselect it there happens nothing :frowning: