user10469186
user10469186

Reputation:

Trouble with Unity Camera Script Expected ";" at line of code

Having Trouble with a expected ";" in the line of

"Vector2 view - new Vector2 (horizontal, vertical);"

Was wondering does anyone know why I am getting this issue?

public class Cam_FPS : MonoBehaviour{
Vector2 Camview;
public float sensitivity;
GameObject mainplayer;

// Start is called before the first frame update
void Start()
{
    mainplayer = this.transform.parent.gameObject;
}

// Update is called once per frame
void Update()
{
    float horizontal = Input.GetAxis ("Mouse X");
    float vertical = Input.GetAxis ("Mouse Y");

    Vector2 view - new Vector2 (horizontal, vertical);
    Camview +- view * sensitivity;

    Camview.y = Mathf.Clamp (Camview.y, -80f, 80);

    transform.localRotation - Quaternion.AngleAxis(-Camview.y, Vector3.right);
    mainplayer.transform.localRotation - Quaternion.AngleAxis(Camview.x, mainplayer.transform.up);


}

}

Upvotes: 0

Views: 51

Answers (1)

BugFinder
BugFinder

Reputation: 17868

You're suffering from code blindness

Vector2 view - new Vector2 (horizontal, vertical);

You meant

Vector2 view = new Vector2 (horizontal, vertical);

Note the equals.. you cant declare a variable and subtract nothing from an unmade container :)

same for Camview +- view * sensitivity; and transform.localRotation - Quaternion.AngleAxis(-Camview.y, Vector3.right); and mainplayer.transform.localRotation - Quaternion.AngleAxis(Camview.x, mainplayer.transform.up); you didnt mean "-" you meant "=" (most likely)

Upvotes: 5

Related Questions