-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
(Automatically?) document classes not being inheritable (virtual, ...) #3460
Comments
I think it can only be extended from C++, not GDScript. cc @Faless |
@Calinou is correct. This means you are not supposed to use Or if you're writing a plugin/module for a new networking protocol or solution like Websockets, create a new C++ class extending Maybe the docs could be clearer here. If you really want to extend the Engine to use Websockets, you'd need to either do this in C++ or maybe using GDNative. Alternatively, the WebRTC stuff here may be of interest: There is also some Websocket stuff here: |
In short, yes I think that's currently not possible. |
Thank you guys for clarification. :)
Not sure if it's the best tool, but it would be the easiest way to do it. My idea was the following (and I was lured into that by the belief you could extend any class available to GDScript).
It looks like it's an easy way to enable higher-level networking with MultiplayerApi, while communicating with our custom server (which is written in Java). I would then just do As for the documentation, it would be nice if each virtual class had a hint saying "This is a virtual class. you can not extend it using GDScript. Consider using C++/GDNative". Something along these lines. Another related question: Is it possible to extend non-virtual classes like Thank you so much for your answers and support, I appreciate! :) 👍 |
You're welcome. :) Thanks for bringing this to our attention, we'll think about making the networking more extendable from GDScript.
For most classes it should be possible, depends on if they're bound/exposed to GDScript and a little bit on how they work.
Again, you're welcome :) I'll rename this issue to be about documenting classes being virtual, as that is a documentation issue, and then I'll open a issue on the main repo about making the networking extendable from GDScript and link it here. |
As @mhilbrunner mentioned, the main reason for not having a GDScript implementable interface for It's also worth mentioning, that the Godot WebSocket implementation already supports the MultiplayerAPI. |
In this section of the documentation, it says:
Since I need to implement a custom client (based on web socket), but want to use the higher-level networking like
get_tree().set_network_peer(my_custom_client)
and rpc() later on, I went ahead and tried to extendNetworkedMultiplayerPeer
. This is the minimal example I came up with:However, turns out the super class is a virtual class, and I can't create a new instance with
MyPeer.new()
. The Error log says:Is there a simple trick I just don't know about? Or is it entirely impossible to provide an implementation of
NetworkedMultiplayerPeer
in GDScript? If the latter is the case, please clarify on how to provide an custom implementation of NetworkedMultiplayerPeer.The text was updated successfully, but these errors were encountered: