I’m trying to use .MemberwiseClone() on a custom class of mine, but it throws up this error:
Cannot access protected member 'object.MemberwiseClone()' via a qualifier of type 'BLBGameBase_V2.Enemy'; the qualifier must be of type 'BLBGameBase_V2.GameBase' (or derived from it)
What does this mean? Or better yet, how can I clone an Enemy class?
Within any class
X, you can only callMemberwiseClone(or any other protected method) on an instance ofX. (Or a class derived fromX)Since the
Enemyclass that you’re trying to clone doesn’t inherit theGameBaseclass that you’re trying to clone it in, you’re getting this error.To fix this, add a public
Clonemethod toEnemy, like this: