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. Dismiss Notice

Error building Player because scripts had compiler errors in the editor (Without The Editor Script)

Discussion in 'Scripting' started by Funkdahoe, May 6, 2021.

  1. Funkdahoe

    Funkdahoe

    Joined:
    May 6, 2021
    Posts:
    6
    I keep getting the error (Error building player because scripts had compiler errors in the editor. this is what my code looks like (p.s. it's probably obviously wrong to all of you but I just started this week)

    Screenshot 2021-05-05 204848.png using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;

    public class PlayerMovement : MonoBehaviour
    {
    public float moveSpeed;
    public Rigidbody2D rb;
    private Vector2 moveDirection;

    // Update is called once per frame
    void Update()
    {

    }

    private void FixedUpdate()
    {
    Vector2 vector2 = new Vector2(moveDirectiion.x * moveSpeed, moveDirection.y * moveSpeed);
    rb.velocity = vector2;
    }

    void ProcessInputs()
    {
    float moveX = Input.GetAxisRaw("Horizontal");
    float moveY = Input.GetAxisRaw("Vertical");

    moveDirection = new Vector2(moveX, moveY);
    }
    }
    }
     
  2. Johan_Liebert123

    Johan_Liebert123

    Joined:
    Apr 15, 2021
    Posts:
    474
    Firstly, don't post pictures of your code, it's pointless. Secondly use Code tags, see this: https://forum.unity.com/threads/using-code-tags-properly.143875/

    What is your error. Go into the editor then console to see what the error is. In the code screenshot you put here. I can see that
    moveDirection
    is underlined in red. Meaning there is an error. Please show us the error
     
  3. Lurking-Ninja

    Lurking-Ninja

    Joined:
    Jan 20, 2015
    Posts:
    9,915
    versus
     
    OneFancyRhino likes this.
  4. Funkdahoe

    Funkdahoe

    Joined:
    May 6, 2021
    Posts:
    6
    It says that moveDirection does not exist in the current context (Edit) there was one typo lets see if this works
     
  5. Funkdahoe

    Funkdahoe

    Joined:
    May 6, 2021
    Posts:
    6
    Now ive got a directory not found exception when trying to build and if i try to run the game within unity it says that Rb is not assigned even though i assigned it in the inspector like it said. I know it's probably something small that will clear up fast
     
  6. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,762
    And here is how! You can do it!

    Remember: NOBODY memorizes error codes. The error code is absolutely the least useful part of the error. It serves no purpose at all. Forget the error code. Put it out of your mind.

    The important parts of an error message are:
    - the description of the error itself (google this; you are NEVER the first one!)
    - the file it occurred in (critical!)
    - the line number and character position (the two numbers in parentheses)

    All of that information is in the actual error message and you must pay attention to it. Learn how to identify it instantly so you don't have to stop your progress and fiddle around with the forum.

    How to understand compiler and other errors and even fix them yourself:

    https://forum.unity.com/threads/ass...3-syntax-error-expected.1039702/#post-6730855

    If you post a code snippet, ALWAYS USE CODE TAGS:

    How to use code tags: https://forum.unity.com/threads/using-code-tags-properly.143875/