Hello. I am trying to build a simple prototype based off https://www.youtube.com/watch?v=ulfGNtiItnc (using WebRTC for multiplayer).
So far I followed the tutorial, which I thought was very good, and I got it working with the demo scene. But I wanted to create my own 3D multiplayer scene. Almost got it working I think, but now I'm stuck because I can spawn players and control just my player on the screen, but there's no synchronization going on.
I have a multiplayer synchronizer node in my Player scene that's supposed to be syncing the player position and rotation. And I think I've found a way to set the multiplayer authority. But otherwise I'm stuck.
I'm not seeing anything in the RPC Network logs for either player. They're just empty.
I've tried both of these in the player scene, neither solves my problem but I don't know if they conflict, etc.
func _enter_tree():
set_multiplayer_authority(name.to_int())
print(name, is_multiplayer_authority())
func _ready():
$MultiplayerSynchronizer.set_multiplayer_authority(str(name).to_int())
Also, this is how I'm spawning players when the test scene loads, based on a GameManager.Players list (that works properly):
func _ready():
var index = 1
for i in GameManager.Players:
var currentPlayer: Node = load("res://scenes/Player.tscn").instantiate()
currentPlayer.name = str(GameManager.Players[i].id)
add_child(currentPlayer)
for spawn in get_tree().get_nodes_in_group("PlayerSpawnPoint"):
if spawn.name == str(GameManager.Players[i].index):
currentPlayer.global_position = spawn.global_position
index += 1
And there is a MultiplayerSpawner node in the test scene as well, but I don't know if it does anything.
Any help would be appreciated. I can also provide code samples or the whole project if necessary.
Subscribe and learn more from me about Game Development and Programming!
In this video, we discuss how to use WebRTC with Godot!
Links:
Starter Project: https://github.com/finepointcgi/WebRTC-with-Godot-Tutorial
Finished Project: https://github.com/finepointcgi/WebRTC-with-Godot-Tutorial/tree/Finished-Product
WebRTC plugin: https://github.co...