Skip to main content
3 de 3
se añadieron 2 caracteres en el cuerpo
Israel-ICM
  • 3.6k
  • 25
  • 20
  • 26

A namespace cannot directly contain members such as fields or methods

Quería ver que esta pasando con mi script, básicamente lo que quiero es como en todos los fps shooters quiero mover la cámara con el mouse.

El error es:

Assets/camera.cs(17,10): erros CS0116: A namespace cannot directly contain members such as fields or methods

 public class Camera : MonoBehaviour
    {
        public Camera cam;
        public float mouseHorizontal = 3.0f;
        public float mouseVertical = 2.0f;
        public float minRotation = -65.0f;
        public float maxRotation = 60.0f;
        float h_mouse, v_mouse;
    }
    // Start is called before the first frame update
    void Start()
    {

    }

    // Update is called once per frame
    void Update()
    {
        h_mouse = mouseHorizontal * Input.GetAxis("Mouse X");
        v_mouse += mouseVertical * Input.GetAxis("Mouse Y");

        v_mouse = Mathf.Clamp(v_mouse, minRotation, maxRotation);
        cam.transform.localEulerAngels = new Vector3(-v_mouse, 0, 0);
    }