How to Make an Iron Sight

I am making a fps, and i came upon a slight bump. I made a script that focuses the camera and it should work but my errors always come up as (Assets/Scripts/CamSwitcher.js
(3,8): BCE0043: Unexpected token: Camera) and (Assets/Scripts/CamSwitcher.js
(4,8): BCE0043: Unexpected token: Camera)

Script:
//Script for Revolver Iron Sights
//Camera names are FpsCamera and IronSightCamera
public Camera FpsCamera;
public Camera IronSightCamera;

function Update() {

// Get pressed keys and makes the camera focus on the iron sight

if (Input.GetKeyDown(“Fire1”))
{
IronSightCamera.camera.enabled = true;
FpsCamera.camera.enabled = false;

}

//Gets the key let up and makes the camera focus on the main fps controller

if (Input.GetKeyUp(“Fire1”))
{
GameObject.IronSightCamera.camera.enabled = false;
FpsCamera.camera.enabled = true;
}
}

Please Help, the game is for a project

Thanks ahead of time

  • Jordan

1 Answer

1

You’re mixing JS and C# syntax, you need to pick one.

JS: public var cam : Camera;

C#: public Camera cam;

thank you soo much