Objects ,variables

Updated on August 10, 2017 in Answers
Share on Facebook0Tweet about this on TwitterShare on Google+0Share on Reddit0
2 on August 9, 2017

Hey everyone
I’m a beginner at C#, i watched one of Brackey’s courses “How to make a Video Game” and i have a question
he uses Rigidody Class  for an object like a Cube
public class MoveScript : MonoBehaviour
{
    public Rigidbody RB;

}
my question is about RB
when we add our OBject to RB variable, is it like the “new” we use for defining a object from a class?? for EX :
{
Myclass (object’s name) = new Myclass() ;

}

Thanks alot

 

 

  • Liked by
Reply
1 on August 10, 2017

No it’s not. Rigidbody is a reference value (check reference vs value types) and by assigning it in the inspector you’re assigning a reference to it so Unity knows where to find that component on which game object.

on August 10, 2017

Thanks for the answer, i learned something new…

Show more replies
  • Liked by
Reply
Cancel