Search Unity

Compiler issue with script

Discussion in '2D' started by Hauwin, Sep 14, 2019.

?

Script has the same name as built-in unity component

  1. script

    0 vote(s)
    0.0%
  2. script

    0 vote(s)
    0.0%
  1. Hauwin

    Hauwin

    Joined:
    Jun 18, 2019
    Posts:
    2
    I am completely new to scripting and coding. I have tried to write a character control script, with inspiration from youtube, and I came across a problem, which disables me from entering play-mode. I am having difficulties explaining the problem, so I have uploaded a picture. If any further information is required to understand the problem (which is probable) please specify the information needed and I shall inform you. Thanks a lot beforehand. The problem has to with my script apparently having the same name as a built.ind unity component
     

    Attached Files:

  2. Valjuin

    Valjuin

    Joined:
    May 22, 2019
    Posts:
    116
    You have already identified that there is a conflict between the name of your script and Unity’s built-in Character Controller component.

    The solution is to use a different script name. As the script is attached to your Body GameObject, you could rename it, for example, BodyController.

    You need to change both the name of the script and the name of the class within that script, as the class name and file name must be the same to enable the script component to be attached to a GameObject.

    The red warning icon in the Console window indicates that there is also an error in your code. Double-click on this error message and the script will open and should take you to the line where the error is (in this case line 20, column 68, or the 68th character position from the left).

    If you need help to fix the error, you will need to post your code, in which case, please use code tags to make your code easier to read.

    Using code tags properly
     
  3. Hauwin

    Hauwin

    Joined:
    Jun 18, 2019
    Posts:
    2
    Hello mate. Thank you so much for the response, what great community.

    Im home from work later today and i will check it out then