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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

3D AddForce not working

Discussion in 'Getting Started' started by Not_Ske11y, Oct 9, 2023.

  1. Not_Ske11y

    Not_Ske11y

    Joined:
    Apr 25, 2023
    Posts:
    2
    When i was making a unity project, I made a public Rigidbody component. (ill name it Movement)
    It seems to work fine but when I add Movement.AddForce(0, 0, 500 * Time.deltaTime)
    I get an error saying: "the variable Movement of Movingscript has not been assigned."
    What confuses me is that it says the variable Movement of movingscript.
    And movingscript is the name of the script.
    It seems to appear by
    public class MovingScript : MonoBehaviour
    which if I remove nothing works.
    I have 999+ errors right now, hundreds of errors every second,
    just slowing down my computer, and I cant find anything on google.
    (I also soon tried tutorials, but it seems like nobody had the same error as me).
    To make sure I wasn't doing anything wrong I copied EXACTLY what the tutorial said to do, and yet it still doesn't work.
    Im on 2021.3.23f1 LTS. Do I have to update my unity project? Because the tutorials I followed all were on 2019 LTS or 2020 LTS.
     
  2. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    10,563
    AddForce works perfectly fine but this isn't a physics post, it's a post for the Getting Started forum because you're clearly new to C# which is fine of course but it's telling you that it has no idea what "Movement" is i.e. you're not following the tutorial correctly.

    It seems you didn't though unless someone put out a tutorial that doesn't compile.

    I'd say, go back to the tutorial and compare your code to theirs again.

    I'll move your post for you.
     
  3. Not_Ske11y

    Not_Ske11y

    Joined:
    Apr 25, 2023
    Posts:
    2
    thank you!