Search Unity

ERRORS!!!!!!

Discussion in 'Documentation' started by Ninjocs, Feb 19, 2017.

  1. Ninjocs

    Ninjocs

    Joined:
    Feb 19, 2017
    Posts:
    5
    I have 5 errors on a script i checked There wasnt these eroors what should i do


    my text:

    import UnityEngine.UI;

    var TheDistance : float = PlayerCasting.DistanceFromTarget;
    var TextDisplay : GameObject;

    var TheDoor : GameObject;

    function Update () {
    TheDistance = PlayerCasting.DistanceFromTarget;
    if (input.GetButtonDown("Action")){
    if (TheDistance <= 2) {
    }

    function OnMouseOver () {
    if (TheDistance <= 2) {
    TextDisplay.GetComponent.<Text>().text = "Press Button";
    }
    }

    function OnMouseExit () {
    TextDisplay.GetComponent.<Text>().text = "";
    }


    my errors:

    Expecting (, found 'OnMouseOver
    Expecting semicolon at the end x2
    expecting ( found 'OnMouseExit'
    expecting } found ''.

    Plz help
     
    Last edited: Feb 19, 2017
  2. JasonBricco

    JasonBricco

    Joined:
    Jul 15, 2013
    Posts:
    956
    In your update method, what is the if check that checks for distance <= 2 doing there? You don't have any code following it. And you only have one curly brace '{', which is causing the error.

    For your OnMouseExit, a semicolon does not go after the opening curly brace.

    I would suggest reading up on the basic syntax for UnityScript to help yourself understand these things better.
     
  3. Ninjocs

    Ninjocs

    Joined:
    Feb 19, 2017
    Posts:
    5
    thank you man it works now! :|
     
  4. Ninjocs

    Ninjocs

    Joined:
    Feb 19, 2017
    Posts:
    5
    nevermind still have them..
     
  5. Ninjocs

    Ninjocs

    Joined:
    Feb 19, 2017
    Posts:
    5
    i copied exactly like a youtuber and these pop up so....
     
  6. DanielQuick

    DanielQuick

    Joined:
    Dec 31, 2010
    Posts:
    3,137
    Please use code tags when posting code. Also use a more descriptive title in the future. "ERRORS!!!!" doesn't tell me anything about your issue.

    I don't see what this problem has to do with Unity Documentation...

    As for your errors, delete these two lines as they aren't doing anything and don't have corresponding ending braces.
    Code (csharp):
    1. if (input.GetButtonDown("Action")){
    2. if (TheDistance <= 2) {