Noob here, can't import unity variables in C# editor, can't display public variables in inspector

Hi guys, just starting fresh trying to follow some tutorials. Tutorial vid is getting different results using what is, as far as I can tell, the same method I am using. I am using visual studio 2019 to edit C# and it doesn’t seem to be importing the types form unity. I’d really like to get started on this project, but I hit a roadblock right away.

Please help!

This is my error:

Assets\PlayerMovement1.cs(7,12): error CS0246: The type or namespace name ‘RigidBody’ could not be found (are you missing a using directive or an assembly reference?)

and this is my script:

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

public class PlayerMovement1 : MonoBehaviour
{
    public RigidBody rb;

    // Start is called before the first frame update
    void Start()
    {
        Debug.Log("Hello, World!");
    }

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

**EDIT: I have this script attached to a cube that is using rigidbody

Rigidbody, not RigidBody. Capitalization is important and must be exact.

Wow, thanks. It had to be something like that… I come from a VB environment that never cares about caps. Thanks for the tip.

Would be easier to get the autocomplete function in visual studio running for the Unity variables… I don’t suppose there’s an easy way to link those features that you know of?

It should just sort of work assuming you open the script file from within Unity.

Try the steps suggested here.

1 Like

I suggest avoiding similar names of existing functions and component names. Or at least putting a ‘_’ in front of the variable name. Also, if you’re not going to access the attached rigidbody component from any other class, you might as well mark it [SerializeField] private. :smile:

2 Likes