0 votes

I want to create a small strategic game and want to create an interface elements that displays a abstract ressource, for example military power, and gives the player an explanatory tooltip when hovering over the display.

For that I have created an Overlying Node named "Tooltip Display", a child node named "Simple Display" and a Panel called "Tooltip". The Tooltip display is the whole 2d element, the simple display is just displaying the ressource value and sends a signlal to the tooltip display when the mouse enters or leaves it. This then makes the tooltip visible or invisible.

The thing is that I have created multiple versions of "Simple Display", all inheriting from "Simple Display" that display different textures and labels based on what ressource is being displayed. The are named "Simple Military Display", "Simple Diplomatic Display" and so on.

I thought these would be interchangable with the standart "Simple Display", since they are it's children, based on how inheritance generally works in object oriented programming languages. So that if I had a scene that needs a "Simple Display", I could also give it a "Simple Military Display".

But when I try to create a child of the "Tooltip Display" to create a specific "Military Tooltip Display" and exchange the "Simple Display" for a "Simple Military Display", I can't seem to. I am guessing that's because the new child inherits from "Tooltip Display and can thus only add nodes, not remove them. Is there a way to override a node with a node that inherits from it in a situation like this?

I know I can just not create the "Simple Display" scenes and manage any changes to it for different ressources from the parent "Tooltip Display" instead, but I am learning godot, so I would like to ask, just to better understand how this node inheritance works.

Can someone tell me if this is possible?

Godot version 3.3.4
in Engine by (12 points)

I think you're mixing concepts here - the nodes in the tree don't inherit from each other; it is just a hierarchy, a collection of nodes similar to a file structure. There's some interplay between them, such as positions but beyond that the individual nodes are independent.

It's tough to figure out what you're doing here without screenshots and/or seeing the project - I guess there's some UI interplay that's making things difficult for you but generally you can achieve what you're after. Reorganising the Scene Tree will help. If you want a parent to show/hide different child nodes, a naive approach is to simple show/hide the child nodes.

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.