Multiple inheritance substitute in Godot

Started by
0 comments, last by Maggistrator 1 year, 3 months ago

Let's assume we have a wall and a pot. They both can be broken by player in the same way, only animations and sounds would be different. I've tried to create service node, that inherits from Area2D and consists of animation player, sound stream player and script, that process hits and triggers animations and sounds. I wrote it (here is the script: https://pastebin.com/5Q6AtCfy​ link button doesn't work for me for some reason), but resulting node has flexibility issues as Godot don't show this node internal structure in user nodes, and it became hard to actually use Godot's UI features to tweak it. Like, I need to store animations in filesystem now to use them in UI fields. Moreover, if I animate objects property, I have to keep that in mind when editing it, because animation probably would not notify me if I break something. In the end, you begin to question yourself, what types should be used to store animation arrays and sounds, how should they load and be edited from UI and it complicates both the service object itself and it's user-nodes. My question is: have I even chose the right way from the start? Or I shouldn't worry about duplicate parts of objects as Godot already done objects creation simple and flexible enough to ignore some duplication?

UPD: I forgot to add that there will be other complex properties like breakability in game, and one game object should be able to possess multiple of them, like: wall with spikes can be broken, but can also do damage to player just like floor spikes. That why title is about multiple inheritance.

p.s. I'm relatively new to Godot, and was using half-self-written engine before, sorry in advance if question is stupid

Do you like bad guys? Because I'm really bad. At everything.

This topic is closed to new replies.

Advertisement