Similarly to your Rigidbody rigidBody
, you should give your MeshRenderer
variable a full name: meshRenderer
.
Short answer: renderer hides an inherited member.
Long answer: You know how Rick says classes have a bunch of stuff defined already? Well, the same thing is true for any of your classes. The details are not immediately visible, because they’re given in another class, whose functionality yours shares under the hood. That class already has a variable called renderer
, so naming your variable the same can lead to a situation where you accidentally mix those two up.