-
-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Better System for a true OOP workflow #1224
Comments
This is very close to the |
sorry the suggestion wasn't about changing class_name. I have updated my post to reflect that |
@Shadowblitz16 it sounds like you want something like what willnationsdev implemented. |
@Rubonnek no this doesn't have to do with multiple scripts at all. |
I updated one of the pictures to get rid of the add script icon to be more clear |
I actually initially proposed doing something like this way back before even the 3.0 release. I got this huge big PR put together that tried to simulate everything as if they were fully classes, with no things being "attached" to objects. There was a TypeDB instead of a ClassDB, and it synchronized type inheritance between Engine types, scripted types, and even scenes. The editor UI was gonna be updated to kinda merge everything together. I had big plans. But, I did way too much work without consulting anyone about it (the naivete of youth) and was shot down by reduz after he'd had a chance to look at it. The reasons (which were justified, in retrospect):
After receiving this feedback, reduz then attempted to cater to my (and many others') concerns by implementing the
Hides information from users. No-go.
I don't really understand this point. Even if you had scripts simulated exclusively as derived Objects, it would still make sense, for usability reasons, to allow people to right click on a Node and "extend Class" or something to launch a new script editor. And you can already create scripts and scenes from the filesystem dock.
I think we should already be able to do this with script classes, no? Or if you can't drag it into the scene, I'm sure that's a feature you could independently request.
This is already supported with the script class system. If you are wishing for this to be present in C#, know that there is already a draft pull request to add script class support to many other languages in various ways. I've run into problems getting C# to work, but it is still planned. See godotengine/godot#40147.
Hides information from users. No-go. I do have a different proposal I plan to submit to better synchronize the type system, but it won't be nearly as drastic a change as what I once proposed previously, nor what you've proposed here. When it's made, I can link it here. |
@willnationsdev it well it depends on the implementation. |
The problem is that hiding the existence of scripts actually impedes users, in any context, from maintaining the same set of features that they currently support. If I wanted to right now, I could create a "game" which was actually an editor for my own use. And I could empower users to manipulate objects in my game by allowing them to manipulate the script, including changing it's content at runtime based on their modding/editing of features or what-have-you. They could also change the script on an object to effectively change its type or instantly extend it while preserving data. However, if you hide the existence of scripts, and don't expose that functionality to end users at all, then an entire domain of using Godot Engine is cut off outside of the Godot Editor which magically knows of the existence of scripts behind the scenes. The workflow is effective enough as it is in my opinion since, afaik, everything that someone could want to get out of making more "legit" classes has already been implemented with scripts already existing. Can you name an actual feature that you are missing or a bug that occurs due to scripts' existence being public? The only "workflow" improvement I can think of is one of you mentally not knowing of the existence of scripts (slightly "cleaner" concept). But, rather than that being a workflow improvement, doing so would actively inhibit a whole range of workflows (not mentally, but concretely).
The point is that it isn't irrelevant. Hiding the information only restricts how people can use the engine, and for an inadequate reason to justify it. |
then we should be able to attach multiple scripts. |
@willnationsdev
the idea of this was to only have 1 inheritance hierarchy so game development would be easier. |
I'm not sure how that follows. You've stated that your concern is that Godot's inheritance/type system is too complex. We outlined how hiding scripts' existence isn't an appropriate solution. Given that, how is going the other direction and supporting multiple script inheritance simultaneously something that solves the problem? If anything, it drastically increases the complexity of that same type system. In fact, they once attempted to implement a scripting language for creating a stack of different languages' scripts, called MultiScript, but it proved far too complex to use or maintain in practice, so they removed it. It never even made it to a stable 3.0 release (godotengine/godot#8718).
The original issue was about abstracting away the differences between engine classes and scripts. Now we are expanding it to scenes as well (which makes sense - part of the "type" system to some extent). It is true that scenes have independent inheritance hierarchies, and that dealing with differences between them and engine classes'/scripts' is a big pain. However, the solution you are alluding to, if I assume correctly, is that we should unify the type system completely and make it so that Godot's API is more similar to that of Unreal's Blueprint system.
Now, assuming my assumptions are accurate, and this is what you intended by your proposal, then here are my thoughts:
Now, even if you could do all of these changes, and you found a way to make it work, the fact of the matter is, I can almost guarantee you that no core developer is going to support it only because the huge amount of development time, research, bug fixing, and documentation updates that such a massively invasive change would require make it prohibitively expensive in terms of labor. The only way I could see this remotely happening is if some extremely motivated individual decides to implement all of these features on their own, just because they wanted to, in a hard fork of the engine. Then, they showcase this hard fork. They demonstrate the concrete changes they had to make. They illustrate, with a concrete implementation, how much better the usability and accessibility of the engine and API have become. They prove that the idea works, that it is possible to convert the main Godot project to that format, etc. And then they convince folks to merge those changes. But even then, it's a big gamble for a lot of work without a guaranteed result. I mean, at a bare minimum, you'd have an alternative version of Godot that supports a different style, but then the motivated individual would be the only one maintaining it while everyone else is moving on with the original project. More than likely, the core devs would instead want to solve the original problem you are having somehow without making such crazy invasive changes. Like creating a dedicated class or global function that facilitates performing the operations you need to handle abstractions for you. Or creating an EditorPlugin that automates editor tasks and manipulates the GUI to make it seem like a ScriptScene system exists rather than what actually exists. And then those would be things that people can just add to the engine to make it work differently if desired. That proposal would be way more likely to be accepted imo. |
so your saying even though it might be a good idea to merge the two inheritance hierarchies into one its most likely not going to happen due to the complexity of the task? |
@Shadowblitz16 Exactly. I mean, I can see how it would be useful, but the main issue I foresee is that point number 4. The way Unreal handles it, you can't visualize code-based scripts at all. In order to visualize them, you have to extend the class into a "Blueprint" which inherits the C++ script functionality and creates a Blueprint file format that supports visualization. But then you are locked into that file type (a non-plain-text data file rather than just script code). The equivalent in Godot would be to mark whether a script is a standalone script, which can be edited anywhere, including an external editor like VS Code, or whether it's a ScriptScene which has visualization as a scene, but a non-script file format that's script can only be edited within the Godot Editor's ScriptEditor (which knows how to navigate the scene format to find the script and update it reliably). This wouldn't impact GDScript, VisualScript, or PluginScript that much (or any other module that uses the ScriptEditor), but it would significantly impact things which rely on an external editor. For C#, the only way to visualize your content in a scene would be to create a derived class which provides visualization, but restricts you to the ScriptEditor (not optimal), so people would be incentivized to either improve the ScriptEditor to accommodate or problematically make all their changes in a base class and just let the derived class in the scene act on the base class's behalf. That is, you'd have faux, empty classes that just inherit another class in order to work around the fact that C# doesn't have good ScriptEditor support. It's certainly doable, but I believe that restriction would make the core devs think not just twice, but many, many times over about merging such changes that limit how people can use the engine. You effectively make the engine a lot more opinionated and controlling about how you work with it for the sake of improving usability. But, until you can prove that all of that work would actually improve usability, it's all just hypothetical and therefore wouldn't necessarily be worth all the effort to build. Now, given the things I've outlined above, it might actually be possible to implement all of the above using addons, now that I think about it. Just create an alternative file format for scenes and build all of your scenes using that file format, rather than the .tscn PackedScene file format. It would also be easy enough to convert a Script/PackedScene to/from a ScriptScene I think. At least, on a basic level. Then you could create this system purely as an option that anyone can apply to their engine, rather than it being a core thing that the developers have to maintain. The only problem would be if the Editor is missing certain hooks to let you edit/access parts of the editor you want to modify to improve the user experience of this plugin. In which case, you'd just need to submit a pull request to expose that access and it would be no big deal. |
@willnationsdev So what about implementing a true type system for nodes and script relations? Scripts would actually be nodes! Scripts could then be dragged into the scene as nodes because they would be them |
Overall, just so far, I'm a little confused by what you mean here.
Here you seem to elaborate on the above comments. The idea being to outsource things inside the engine to external assets that can be fully rewritten in GDNative script code and downloaded from official sources. There are actually plans to do this for the less-often-used nodes in the engine, e.g. VehicleBody. However, a few issues from your idea.
Going back to the "Scripts would actually be nodes!" idea, if you also outsourced the Node and Resource classes so that "all of their methods could be exposed to scripting" in some form or fashion (even if it was only GDNative scripts), then all of the other languages would suddenly be unable to extend the Node or Resource types. Therefore, the core system of Godot wouldn't have any way of communicating. So, at a bare minimum, you'd need Object, Resource, Node, MainLoop, and SceneTree to be in the core rather than in GDNative. But even if you did manage to port most of the If you wanted to add inheritable support for every language, you'd have to re-implement the class in each language, and each language's implementation would have different performance constraints (so a GDScript VehicleBody would execute code much more slowly than a C# or C++ VehicleBody, etc.). In the current form, each language all makes use of the fast engine C++ code, so a GDScript VehicleBody is just as fast as a C# VehicleBody. It's only when you add more and more customized runtime logic on top of the VehicleBody class that you start to see larger differences in performance. Another consideration is the Server classes which are also exposed to the scripting API (RenderingServer, AudioServer, PhysicsServer2D, etc.). If you also want all of their methods exposed so that people can directly implement and override their methods, you'd just be asking for people to wreak havoc with their engine runtimes if they don't know what they're doing. Would need tons of documentation. Although, I do think there are plans to make it easier for people to provide their own implementations of the physics server in later versions of Godot (like 4.1 or something). And the RenderingDevice/RenderingServer code is already being massively redesigned to allow people to more easily customize the rendering pipeline in Godot 4 thanks to reduz's work. My point being, the more stuff you move out of the core, the slower Godot becomes and the more difficult you make it for users to freely extend and use the stuff in the engine. So, while there are plans to do this, it is only for a handful of types, and mostly for things which don't require heavy customization to be useful. That, or they are for standalone systems that are to be swapped out in their entirety (like swappable Server implementations).
Isn't this already doable for any script that extends Node? I know it is for scenes, but I would've thought scripts supported it too. If not, then wouldn't be too difficult to implement, I would think. Double-check, and if it isn't, you can open a proposal for it. |
@willnationsdev see #1876 I think it may be a better implementation and might be more inlined with godot's design philosophy |
Reopening this. Its much easier to just inherit something and create it then attach a script that might be removed. Godot talks about its design philosophy as being the reason we don't have a multi script/unity3D like ecs workflow, also what even makes it a script vs a new object? a script does exactly that it creates new objects so I don't see your point |
As far as I know, GDExtension makes it relatively easy to add your own full-fledged classes, including However, it seems to me that in theory we can change the UI of the editor in such a way that there will be an illusion of full-fledged classes (lack of the Attach Script button, etc.). But this is a lot of work, which is definitely too late to start for 4.0. Maybe for 5.0. And I'm not sure it will bring much benefit. Although, I imagined it, and it seems to me that it will improve the user experience and, in a sense, change the minds of users a little. I can draw some mockups if you like. |
@dalexeev can you? I think most of my suggestions are shutdown because I can't properly communicate to other people due to my disabilities. It's kinda the reason why I get frustrated and close my issues |
This may come with gdscript and C# being ported to gd extension |
Describe the project you are working on:
Spaceship game
Describe the problem or limitation you are having in your project:
I just find it difficult to work with godot's OOP nature when godot's scripts don't truly extend anything just add logic for it
Describe the feature / enhancement and how it helps to overcome the problem or limitation:
Basically the idea is to get rid of scripts attached to nodes and introduce a true OOP script system.
Basically the way it would work is scripts would no longer be attached to nodes but instead the scripts would be the nodes!
for example...
Describe how your proposal will work, with code, pseudocode, mockups, and/or diagrams:
If this enhancement will not be used often, can it be worked around with a few lines of script?:
This would be used more then you would think especially in C#
Is there a reason why this should be core and not an add-on in the asset library?:
Godot is OOP by design however it feels like it uses some weird one script ecs even though its actually just oop.
why not abstract the layer away?
The text was updated successfully, but these errors were encountered: