Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Mouse look around first person ERROR CS1514

Discussion in 'Scripting' started by TheSuperSp33dyS, Nov 27, 2020.

  1. TheSuperSp33dyS

    TheSuperSp33dyS

    Joined:
    Nov 25, 2020
    Posts:
    28
    I want the body to turn around whenever I move the mouse, so that it can look around, yet I get an error. I am using Unity 2020.1.14 and I get this error cs1514. Can someone please tell me what is wrong?

    using UnityEngine;
    public class MouseLook : MonoBehaviour
    public float mouseSensitivity = 100f;
    public Transform playerBody;
    {
    // Start is called before the first frame update
    void Start()
    {

    }
    // Update is called once per frame
    void Update()
    {
    float mouseX = Input.GetAxis("Mouse X") * mouseSensitivity * Time.deltaTime;
    float mouseY = Input.GetAxis("Mouse Y") * mouseSensitivity * Time.deltaTime;
    playerBody.Rotate(Vector3.up * mouseX);
    }
    }
     

    Attached Files:

  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,517
  3. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,888
    Missing opening curly brace in the class declaration... Please look at any Unity code sample to compare with.