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

Bug Trouble using Rigidbody2D in script- missing directive or assembly reference

Discussion in '2D' started by edillard, Mar 31, 2022.

  1. edillard

    edillard

    Joined:
    Feb 4, 2022
    Posts:
    6
    Error message:
    Assets\Scripts\PlayerMovement.cs(8,13): error CS0246: The type or namespace name 'Ridgidbody2D' could not be found (are you missing a using directive or an assembly reference?)

    Code: (errors out on 1st Variable)
    // Class variables
    private Ridgidbody2D rb2d;

    private float moveSpeed;
    private float jumpForce;
    private bool isJumping;
    private float moveHorizontal;
    private float moveVertical;

    I know this is on a lot of posts - and 99% of the people had typos on "Ridgidbody2D"
    I've added a Box Collider 2D component and a Ridgid Body 2D component to my sprite.
    I've run it without a script and if falls and stops when it hits the ground sprite (that also has a Box Collider 2D)
    So I'm pretty sure that it is set up correctly there.
    I'm running the Editor version 2020 3.27f1
    I also noticed that the IDE doesn't auto complete the word Ridgidbody2D - but then it doesn't autocomplete a lot of things. So there may be a Visual Studio C# update that I need to install. I'm running
    Microsoft Visual Studio Professional 2019
    Version 16.10.4
     
    Last edited: Mar 31, 2022
  2. ZBerm

    ZBerm

    Joined:
    Jan 12, 2017
    Posts:
    61
    But it is just a typo, there is no class
    Ridgidbody2D
    you want to use
    Rigidbody2D
    .

    Have a google for fixing Intellisense in visual studio for unity, it breaks all the time.
     
  3. edillard

    edillard

    Joined:
    Feb 4, 2022
    Posts:
    6
     
  4. edillard

    edillard

    Joined:
    Feb 4, 2022
    Posts:
    6
    I'm sorry - I just found the typo.
     
  5. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    10,620
    What I don't get is that you even stated what the problem was in your question so..... !!?!!! o_O

    You should still be able to use notepad if you wanted. Saying intellisense isn't doing X isn't a reason to be stuck or have to post because you misspelled something. The main thing is to start to use the Scripting Reference if you're ever in doubt of naming, capitalization etc. It has a search feature that will quickly find what you want too.

    https://docs.unity3d.com/ScriptReference/Rigidbody2D.html
     
    Chris-Trueman likes this.