0 votes

I'm using Godot 3.2.1 stable. In this section of the documentation, 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
3 class MyPeer extends NetworkedMultiplayerPeer:
4     func _init():
5           pass
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
  <C++ Source>  core/class_db.cpp:540 @ instance()
  <Stack Trace> Node.gd:7 @ _init()
E 0:00:00.772   _new: Can't inherit from a virtual class.
  <C++ Error>   Condition "!owner" is true. Returned: Variant()
  <C++ Source>  modules/gdscript/gdscript.cpp:158 @ _new()
  <Stack Trace> 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?

in Engine by (24 points)
edited by

1 Answer

0 votes
by (24 points)
edited by
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 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 webmaster@godotengine.org with your username.