Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more..
    Dismiss Notice
  3. Dismiss Notice

Errors in code arent showing up

Discussion in 'Visual Scripting' started by ChipotleGod, Aug 31, 2020.

  1. ChipotleGod

    ChipotleGod

    Joined:
    Jul 20, 2020
    Posts:
    48
    When I try to press play it says "all compiler errors have to be fixed before you can enter playmode!" I check the script and it says I have no errors. Does anyone know whats going on?
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class MouseLook : MonoBehaviour
    6. {
    7.    
    8. public float mouseSensitivity=100f;
    9.  
    10. public Transform playerBody;
    11.  
    12.  
    13. // Start is called before the first frame update
    14.     void Start()
    15.     {
    16.        
    17.     }
    18.  
    19.     // Update is called once per frame
    20.     void Update()
    21.     {
    22.         float mouseX= Input.GetAxis("Mouse X");*mouseSensitivity*Time.deltaTime;
    23.         float mouseY= Input.GetAxis("Mouse Y");*mouseSensitivity*Time.deltaTime;
    24.  
    25.         playerBody.Rotate(Vector3.up*mouseX);
    26.      
    27.         }
    28. }
    29.  
     
  2. Siro13

    Siro13

    Joined:
    Jun 30, 2014
    Posts:
    33
    Hi,
    You posted in the wrong category.
    Anyway, I see some strange:

    float mouseX= Input.GetAxis("Mouse X")-->;<----*mouseSensitivity*Time.deltaTime;

    float mouseY= Input.GetAxis("Mouse Y")-->;<----*mouseSensitivity*Time.deltaTime;
     
  3. ChipotleGod

    ChipotleGod

    Joined:
    Jul 20, 2020
    Posts:
    48
    what do you mean you see some strange?
     
  4. Siro13

    Siro13

    Joined:
    Jun 30, 2014
    Posts:
    33
    I mean you have to remove the semicolon in the expression:

    from
    float mouseX= Input.GetAxis("Mouse X")-->;<----*mouseSensitivity*Time.deltaTime;
    float mouseY= Input.GetAxis("Mouse Y")-->;<----*mouseSensitivity*Time.deltaTime;

    to
    float mouseX= Input.GetAxis("Mouse X") *mouseSensitivity*Time.deltaTime;
    float mouseY= Input.GetAxis("Mouse Y") *mouseSensitivity*Time.deltaTime;

    and the error should disappear
     
  5. ChipotleGod

    ChipotleGod

    Joined:
    Jul 20, 2020
    Posts:
    48
    Ohhhhhhh. That worked! Thank you! Sorry to bother you.
     
  6. Siro13

    Siro13

    Joined:
    Jun 30, 2014
    Posts:
    33
    :-D
     
  7. DaffaFrazer

    DaffaFrazer

    Joined:
    Nov 23, 2021
    Posts:
    2
  8. DaffaFrazer

    DaffaFrazer

    Joined:
    Nov 23, 2021
    Posts:
    2
    from brackeys tutorial?