-1
\$\begingroup\$

So for Unity I've been trying to to do the code line public RigidBody2D rb; I've followed the gmetrix unity programming course and they do that just fine with the unity set up code and just this. This then allows them to put the object ubsprite that I and them called player inside the c# program for player. However for me the error CS0246 comes up. I've looked up similar situations and haven't found a fix for mine.

Complete Code

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

public class Player : MonoBehaviour


{
    public RigidBody2D rb;//RigidBody Slot

    // Start is called before the first frame update
    void Start()
    {

    }

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

    }
}

For them RigidBody2D lights up blue however for me it does not and I won't get to be able to add the sprite gameobject into the code slot for it.

Edit: Sorry noticed there are actually a couple of error messages. Hope this image helps from console.

enter image description here

Also to the comment I recieved about the video if I can upload it sadly this course is not publicically available its the simple course for Unity programming however it still provides a certificate and is associated with unity so it is a pay for course or if you are a student teachers can get course keys. It is the gmetrix course associated with unity and certiport for those who wanna know still.

Edit 2: An answer was provided for fixing the error CS0246, however the other 2 errors are still present.

\$\endgroup\$
1
\$\begingroup\$

It's spelled Rigidbody2D, not RigidBody2D. Capitalization matters in C#.

\$\endgroup\$
  • \$\begingroup\$ This has fixed one of the errors however the other errors are still present. Thank you for the help you could provide though. \$\endgroup\$ – Wolf Bot Jan 17 at 19:24
0
\$\begingroup\$

I found the issue! I was looking into the error messages and found a similar post on the unity forums.

--https://forum.unity.com/threads/visual-studio-tools-tab-dont-show-and-cant-attach-to-unity.365416/

One of the people said that there are issues if you have multiple versions of unity or multiple versions of visual studios. I found a few things about this. First some computers already have visual studios installed so you may not need to download visual studio, or if you're upgrading then you need to uninstall the older versions first. Second Unity has an option to download visual studios with it so you don't need to download it if you already have it. It seems that with my computer I had a dozen versions of visual studios. There were was all from 2012-2017 in 32 and 64 bit form. Meaning I had 12 different visual studios installed + 1 more since I had unity download one before. So a total of 13. Anyways I've used stackexchange before and I believe you have to wait 24 hours before you can click your own answer as an answer for your own question so please wait to knock me down tell then.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.