[new here]2nd day, 3 errors: name does not exist in current context

[intro]
Hello guys,
I guess you’ve read this hundreds of times, but …here i go as well:
I’m new here, been unemployed due to current situation so I want to learn Unity.
It’s just my second day here, and i need a little help as I’m stuck.

Problem:
I’m following a tutorial, got to the scripting bit, followed exactly (at least i think so), his script works, mine doesn’t.
I keep getting errors, such as:

***error CS0103: The name ‘thrust’ does not exist in the current context

***error CS1061: ‘Transform’ does not contain a definition for ‘EulerAngles’ and no accessible extension method ‘EulerAngles’ accepting a first argument of type ‘Transform’ could be found (are you missing a using directive or an assembly reference?)

***error CS1061: ‘Vector3’ does not contain a definition for ‘X’ and no accessible extension method ‘X’ accepting a first argument of type ‘Vector3’ could be found (are you missing a using directive or an assembly reference?)

It’s my mistake somewhere, i’m the idiot i guess, but i really want to learn unity :slight_smile: and I guesswe all started somewhere…

Thank you for the help :slight_smile:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class Move : MonoBehaviour
{
    public float rotationSpeed = 5f;
    public float thrustForce = 10f;

    public Joystick joystick

    float rotationX, rotationY;
   
    Rigidbody2D RB;

    // Start is called before the first frame update
    void Start()
    {
        RB = GetComponent<Rigidbody2D>();
    }

    // Update is called once per frame
    void Update()
    {
        if (joystick.Horizontal != 0f || joystick.Vertical != 0f) {
            rotationX = joystick.Horizontal * rotationSpeed;
            rotationY = joystick.Vertical * rotationSpeed;
        }
        if (Input.GetButtonDown("Jump")) {
            Thrust();
        }
    }
    private void FixedUpdate()
    {
        transform.eulerAngles = new Vector3(transform.eulerAngles.x, transform.eulerAngles.y, -(Mathf.Atan2(rotationX, rotationY) * Mathf.Rad2Deg));

    }

    public void Thrust()
    {
        Vector2 force = transform.up * thrustForce;
        RB.AddForce(force);
    }
}

(sorry, did not know about the code button :] )


Also, I’ve noticed that GetComponent doesn’t work, and other functions as well,
maybe somehow a library is not linked?
Don’t know, i’m completly new to this :slight_smile:
A beer for the help will be given :smile:

Please use Code Tags when posting code (not images), as described in the very first post in this forum. And when posting errors, post the entire description, including line numbers and make sure they match your code.

1 Like

sorry, didn’t know :slight_smile:

I think I’ve passed the first errors, but now running into this :slight_smile:

Assets\Move.cs(11,29): error CS1002: ; expected

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class Move : MonoBehaviour
{
    public float rotationSpeed = 5f;
    public float thrustForce = 10f;

    public Joystick joystick

    float rotationX, rotationY;
   
    Rigidbody2D RB;

    // Start is called before the first frame update
    void Start()
    {
        RB = GetComponent<Rigidbody2D>();
    }

    // Update is called once per frame
    void Update()
    {
        if (joystick.Horizontal != 0f || joystick.Vertical != 0f)
        {
            rotationX = joystick.Horizontal * rotationSpeed;
            rotationY = joystick.Vertical * rotationSpeed;
        }

        if (Input.GetButtonDown("Jump"))
        {
            Thrust();
        }
    }

    private void FixedUpdate()
    {
        transform.eulerAngles = new Vector3(transform.eulerAngles.x, transform.eulerAngles.y, -(Mathf.Atan2(rotationX, rotationY) * Mathf.Rad2Deg));
    }

    public void Thrust()
    {
        Vector2 force = transform.up * thrustForce;
        RB.AddForce(force);
    }
}

What am I doing wrong?

yeyy, passed so far :slight_smile: missed a semicolon on line 11

Now i get this error:
NullReferenceException: Object reference not set to an instance of an object
Move.Update () (at Assets/Move.cs:26)

Same code as above

That usually means that you did not connect the correct object (it is null - not initialized). How did you connect the joystick you reference in line 26?

Thank you for your help!
I figured it out about 20 minutes ago… I was making changes while i was in Play Mode, and each time i was going out of Play mode, it was “forgetting” all changes… Kept forgetting to hit PLAY again after testing
Oh man, i really love all this headache i’m getting with Unity, and hopefully I’ll get a grip on it :slight_smile: