Why MonoBehavior vs GameObject?

Can anyone explain why the instructor chose the CurrentActiveWeapon to be MonoBehavior vs a GameObject?

So that we can use the currentActiveWeapon as IWeapon. This construction will not work with GameObjects.

You could also make the currentActiveWeapon a GameObject and use

currentActiveWeapon.GetComponent<IWeapon>()

to reference the IWeapon calls.

2 Likes

thanks much!

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms