Void error CS1002

(i have a compiler error (error CS1002) for a void namespace)
here is the code:

public class FirstPersonCamera : MonoBehaviour {

public float mouseSensitivity = 2.0f;
Camera firstPersonCam;
public Camera playerCam;

float rotatePitch;
float pitchRange = 60.0f;
}

void Start();
{
cc = GetComponent ();
firstPersonCam = GetComponentInChildren ();

Cursor.lockState = CursorLockMode.Locked;
}

void CameraMovement()
{
float rotateYaw = Input.GetAxis(“Mouse X”) * mouseSensitivity;
transform.Rotate(0, rotateYaw, 0);

rotatePitch += -Input.GetAxis(“Mouse Y”) * mouseSensitivity;
rotatePitch = Mathf.Clamp (rotatePitch, -pitchRange, pitchRange);
//firstPersonCam.transform.Rotate(rotatePitch,0,0); - REMOVE
FirstPersonCam.transform.localRotation = Quaternion.Euler(rotatePitch, 0, 0);
}

void Update()
{
CameraMovement();
Inputs();
Movement();
}

Please use code tags: Using code tags properly

How to report problems productively in the Unity3D forums:

http://plbm.com/?p=220

2 Likes

There is nothing like a void namespace. When you get an error, at least copy the exact error text The compiler just wonders what the heck the keyword “void” should mean outside any class. All your methods are outside your “FirstPersonCamera” class. Check your brackets and pay attention to your indention. As Kurt said, using proper code tags helps with the formatting here. However When you use a proper IDE like Visual Studio you should already notice that all your methods are outside your class.

In addition you have a semicolon after your void Start() line which makes no sense there.
So remove that semicolon and move all your methods inside your class.

1 Like

You’re ending your class before your Start method. All method declarations must be within a class. Normally the only code you see outside of a class is a namespace declaration or another class declaration, which is probably why the compiler error mentions a bad namespace even though that’s not what you’re doing.

1 Like