Hello all,
Back in lecture 12, I gathered that there are 3 parts to a variable: the Name, Type and Value and if we wanted to create a variable called “Speed” and initialized it with a value of “10.5”, then we can write the variable as:
float speed = 10.5;
I understand what the type “float” is doing here. Similarly, I understand what a type like bool or integer or string is doing when we define a variable that goes along with it. However, cut to this lecture and now I am looking at:
MeshRenderer meshrenderer;
Rigidbody rigidbody;
and I don’t really understand what the “type” is doing here. I know its saying the variable meshrenderer has to be of type MeshRenderer, but what does that exactly mean in this context? What does it mean to have a component of the UnityEngine class as a type for a variable? Why doesn’t it work if we write it as:
string Meshrenderer;
string rigidbody;
I am just a little bit unclear about this issue so if someone can help me out that would be amazing. Cheers!