godotengine / godotengine/godot-docs
(Automatically?) document classes not being inheritable (virtual, ...)
- Dominant language
- reStructuredText
- Stars
- 5.7k
- Forks
- 3.8k
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 25
Description
In [this section of the documentation][1], it says:
> Godot uses a mid-level object NetworkedMultiplayerPeer. This object is not meant to be created directly, but is designed so that several implementations can provide it.
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 extend `NetworkedMultiplayerPeer`. This is the minimal example I came up with:
1 extends Node
2
3 class MyPeer extends NetworkedMultiplayerPeer:
4 func _init():
5 pass
6
7 var peer = MyPeer.new()
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:
E 0:00:00.772 instance: Condition "!ti->creation_func" is true. Returned: __null
core/class_db.cpp:540 @ instance()
Node.gd:7 @ _init()
E 0:00:00.772 _new: Can't inherit from a virtual class.
Condition "!owner" is true. Returned: Variant()
modules/gdscript/gdscript.cpp:158 @ _new()
Node.gd:7 @ _init()
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.
[1]: https://docs.godotengine.org/en/3.2/tutorials/networking/high_level_multiplayer.html#mid-level-abstraction
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.