New component vs Inheritance

I’m curious to hear Ben’s pros and cons in this case. My natural inclination is to extend the player/pawn class to give grabbing properties/methods. Or maybe extend the Chair class to add grabbable properties/methods. Or both? (Talked myself into one of these answers below…)

When 1 type of object wants to interact with another type of object, there are 2 different objects that can be extended, or a new component that handles the interaction between these - or even all 3 places to write small amounts of code would be best.

What we don’t want is the Pawn to be able to grab every object in the known universe. So extending Pawn to give the ability to grab anything (and the control what can be grabbed with an if statement) doesnt feel as clean as extending the static mesh object class, adding grabbable methods and a property (e.g. checkbox) that indicates whether this object can be grabbable. That way the game designer can choose which objects to make grabbable.

Whether or not we additionally need a new component or not, no idea… on to the lecture…

Hmm, seems that keeping Player (Pawn) state is a really important principle. I would never have guessed the answer to be honest, but it does make sense now that I’ve finished this lecture…

I think it might just come down to composition over inheritance.

1 Like

Privacy & Terms