#Multiple Instances Using Same WebRTCMultiplayerPeer instance
19 messages · Page 1 of 1 (latest)
That code itself doesn't do anything to connect the various instances to each other.
You simply create a peer to peer mesh network in the code and then output that into the console, so it seems that the behavior matches the code you posted.
Inherits: MultiplayerPeer< PacketPeer< RefCounted< Object A simple interface to create a peer-to-peer mesh network composed of WebRTCPeerConnection that is compatible with the MultiplayerAPI. Descr...
@gloomy magnet but shouldn’t each instance have their own WebRTCMultiplayerPeer ? Seems confusing to do the connecting part when all 4 instances are using the same WebRTCMultiplayerPeer instance
I already have all the connecting code done, but my whole issue is that all my instances are using the same WebRTCMultiplayerPeer instance
well with that you create a client and a server, that then connect to each other. when you create these instance classes locally why would they be different?
when you say you have all the connecting code done, does thst mean everything works?
once they connect to your host or the host sets up the game they all have unqieu id's assigned
host 1, other okays a combination of numbers
based on your snippet alone you would see the same result since you're just outputting an new rtc_mp class.
@gloomy magnet here's my connection code:
func _connected(id, data, use_mesh):
print("56: Connected %s, mesh: %s, data: %d" % [id, use_mesh, data])
if use_mesh:
rtc_mp.create_mesh(data)
elif data == "1":
rtc_mp.create_server()
else:
rtc_mp.create_client(data.to_int())
multiplayer.multiplayer_peer = rtc_mp
print("66: MULTIPLAYER: ", multiplayer)
print("67: MULTIPLAYER::PEER: ", multiplayer.multiplayer_peer)
I noticed after some debugging that rtc_mp.create_server nor rtc_mp.create_client is ever hit this is because use_mesh is always true in my case. I'm I miss understanding this demo ?
when I run this print here but for the demo all the instances print a different class instance id for WebRTCMultiplayerPeer, I'm confused why my project is using the same WebRTCMultiplayerPeer instance, it doesn't make sense how do I connect the same instance to itself?
I can't tell you how the demo is made and what changes you did, but if you use some of the existing code like extending from "ws_webrtc_client.gd" that script has custom set up signals.
https://www.youtube.com/watch?v=n8D3vEx7NAE I followed this tutorial which was highly instructive. The demo project looks quite complicated to parse if you just started with multiplayer stuff
How to make a simple online multiplayer FPS game in Godot 4 and play with friends over the internet. Big thank you to @ditzyninja for his Godot 4 networking content!
Git Repo: https://github.com/devloglogan/MultiplayerFPSTutorial
0:00 Intro
=== Blender Modeling ===
0:34 Environment Model
3:48 Pistol Model
=== Godot 4 Project Setup ===
6:56 Im...
I would start completely fresh and set up your own project with all the networking code written yourself, following this or other tutorials
Trying to use the Demo project and changing up some code will likely just frustrate you
I noticed after some debugging that rtc_mp.create_server nor rtc_mp.create_client is ever hit this is because use_mesh is always true <- You are connecting to a signal on ws_webrtc_client.gd, because thats what the client script extends from, so you'll have to adjust signal connected(id, use_mesh) accordingly if you want to get other information from it
On a side node, please ask the person before PMing them out of the blue 🙂
When did I pm you lol ?
In case anyone comes across this I had a missing piece in my signaling server where on PEER_CONNECT I was sending PEER_CONNECT to existing peers, but not sending the new peer the PEER_CONNECT of existing peers. I also did some script restructering in fear of my WebRTCMultiplayerPeer being a singleton.