hiding inherited members

I get this warning:

Assets/_Scripts/Player/PlayerController.cs(25,31): warning CS0109: The member 'PlayerController.rigidbody' does not hide an inherited member. The new keyword is not required

As soon as I remove the new keyword, I get:

Assets/_Scripts/Player/PlayerController.cs(25,27): warning CS0108: 'PlayerController.rigidbody' hides inherited member 'UnityEngine.Component.rigidbody'. Use the new keyword if hiding was intended

Those inherited members are obsolete, is there any way to use them without getting warnings?

I had the same issue.

public Rigidbody rb;
void Start() {
    rb = GetComponent<Rigidbody>();

Got solved.

I belive you are not ment to use rigidbody any more but to use


instead in its place

As far as i know there’s currently no valid way to reintroduce a “rigidbody” variable.

You could use a pragma warning directive to disable the warning. I’m not sure which way would be the best, but i guess i would use the “new” keyword and disable “109”. The best valid way is to use a different name such as “rb” instead of “rigidbody”.