It is easy. It's difficult if you're not accustomed to programming with an observer pattern (which most game engines use) or not accustomed to creating your objects via composition rather than inheritance (which is just a preference thing). Neither of these styles are focused very heavily on in computer science programs.
Inheritance is an "is a" relationship, while composition is a "has a" relationship. If you think about it in an inheritance way: a Tank
is a Vehicle
so it makes sense that a Tank
would inherit from a Vehicle
class. Tank.move()
would likely just call Vehicle.move()
.
If you think about it in a composition way: a Vehicle
really is just an object that moves so a Tank
and a Vehicle
could just have a Mover
class that they act on when they want to move. Tank.move()
or Vehicle.move()
could just call Mover.move()
.
Tank
s in both situations will likely have a Turret
to shoot out of. So in the inheritance case: a Tank
is a Vehicle
that has a Turret
OR a Tank
inherits from the Vehicle
class and is composed of a Turret
. In the composition case: a Tank
has a Mover
and a Turret
OR a Tank
is an object that is composed of a Mover
and a Turret
.
There are many ways to skin a cat while programming. It is initially difficult moving from what you learn in a computer science based curriculum, which generally favors inheritance and using the command or chain of responsibility patterns to a system that limits inheritance and uses an observer pattern. I assure you that you can solve any problem that you want to solve in Godot, you'll probably just have to go at it a different way than you're used to.
https://en.wikipedia.org/wiki/Composition_over_inheritance
https://en.wikipedia.org/wiki/Object_composition