- Home /
member variable "controller" defined by Component class?
Hi,
in my code I have a controller script extending MonoBehavior. I need a reference to a BoxCollider2d which I assign normally with GetComponent. When I name the reference:
BoxCollider2d collider;
I receive a compiler warning: "Controller2d.collider hides inherited member 'UnityEngine.Component.collider'.Use the new keyword if hiding was intended"
Ok so the Component class defines a member called "collider" I thought. but the script reference of the Component class does not mention the member variable. Also creating an empty script extending MonoBehavior does not bring up the variable "collider" in the code-completion.
Can anybody explain the warning? I could make it go away by choosing a different name like boxCollider, but I would like to understand where this warning is coming from.
Thank you. kind regards Fred
Answer by fredzh · Feb 16, 2016 at 09:48 AM
Found this: Question answered.
Removed in version 5.3.2p2 Property collider has been deprecated. Use GetComponent() instead. (UnityUpgradable)
Your answer
![](https://koobas.hobune.stream/wayback/20220612064414im_/https://answers.unity.com/themes/thub/images/avi.jpg)