Hello! Fairly new to Godot but experienced gamedev/programmer here. I have a design question about a problem I stumbled upon. I want to have buildings and units that can be damaged. I want to be able to damage things without knowing if it's a building or a unit, and I don't want to duplicate the damageable logic. So I came up with the straightforward class diagram attached as a picture.
My problem is that Building is a StaticBody3D and Unit is a CharacterBody3D (or KinematicBody3D for Godot 3.x) hence I can't have a single hierarchy. So far I for-see the following solutions:
- Make
DamageableextendsCharacterBody3D, the buildings will be dynamic bodies. Simple and should work. - Make
DamageableextendsNodeand add the 'logic' node as a child of the root body node. Kind of like a composition I guess? Seems more 'correct' but requires more work and might introduce coupling.
Any though or other ways/patterns to solve this in an elegant manner? Would love to ear how experienced Godot dev solve this :)