Search Unity

Ruby's Adventure Script is bugged/Has an error!

Discussion in 'Scripting' started by csprinks, Jun 1, 2019.

  1. csprinks

    csprinks

    Joined:
    Jun 7, 2016
    Posts:
    4
    I have got up to Step 11/12 in this tutorial and the game is telling me there is an error in the code. I know next to nothing about how to code and I don't know how to fix it.

    Here is the code as of part 14. I copied and pasted it verbatim from the end of that part of the tutorial:
    public class RubyController : MonoBehaviour
    {
    // Start is called before the first frame update
    void Start()
    {
    }
    // Update is called once per frame
    void Update()
    {
    float horizontal = Input.GetAxis("Horizontal");
    float vertical = Input.GetAxis("Vertical");
    Vector2 position = transform.position;
    position.x = position.x + 3.0f * horizontal * Time.deltaTime;
    position.y = position.y + 3.0f * vertical * Time.deltaTime;
    transform.position = position;
    }
    }
    Compiler Error is attached.

    I'm at a loss. :(
     

    Attached Files:

  2. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,188
    Doesn't look like compiler errors. If you clear, do any of the errors stay up?
     
  3. csprinks

    csprinks

    Joined:
    Jun 7, 2016
    Posts:
    4
    Yes the following:
    Assets\Scripts\RubyController.cs(1,31): error CS0246: The type or namespace name 'MonoBehaviour' could not be found (are you missing a using directive or an assembly reference?)
     
  4. csprinks

    csprinks

    Joined:
    Jun 7, 2016
    Posts:
    4
    Anyone have thoughts on this?
     
  5. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,188
    Can you post your version of that script with code tags?
     
  6. DonLoquacious

    DonLoquacious

    Joined:
    Feb 24, 2013
    Posts:
    1,667
    My first impression is that you may be missing using UnityEngine; at the top of the script. Especially if you copied+pasted it from a tutorial of some sort, as they tend to leave little details /s like that out at times. But yeah, code tags. Always code tags.
     
  7. Invertex

    Invertex

    Joined:
    Nov 7, 2013
    Posts:
    1,550
    It also seems like perhaps you didn't install Visual Studio when you installed Unity and it's having issue with that.
     
  8. csprinks

    csprinks

    Joined:
    Jun 7, 2016
    Posts:
    4
    I did install Visual Studio, it's what I'm using to write the code. When I get home I'll post my code.