Skip to content
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

multiplayer.is_server() returns true by default #92066

Open
dev-cyprium opened this issue May 18, 2024 · 3 comments
Open

multiplayer.is_server() returns true by default #92066

dev-cyprium opened this issue May 18, 2024 · 3 comments

Comments

@dev-cyprium
Copy link

Tested versions

  • Reproducable in v4.2.2.stable.official [15073af]

System information

Godot v4.2.2.stable - Windows 10.0.22631 - Vulkan (Mobile) - dedicated NVIDIA GeForce RTX 3070 (NVIDIA; 31.0.15.5244) - AMD Ryzen 7 3700X 8-Core Processor (16 Threads)

Issue description

multiplayer.is_server() returns true in a fresh project. It's not stated like that in the documentation.

Steps to reproduce

  • Create a new Godot project
  • in the _ready() function simply print(multiplayer.is_server())
  • the returning value is true even though the peer is Offline

Minimal reproduction project (MRP)

TEst.zip
TEst.zip

@dev-cyprium
Copy link
Author

The use case was in my actual project I have this logic:

func _ready():
	GuiSignalManager.role_selected.connect(_on_role_selected)
	GuiSignalManager.role_changed.connect(_on_role_changed)
	margin_container_pane.hide()
	Console.attach(self)
	
	if multiplayer.is_server():
		Console.write_line("WINDOW IS SERVER!! menu.gd:25")
		host_options.visible = true

The host_options are visible for both the server and the client, so I was wondering if this should be false initially?

@Summersay415
Copy link
Contributor

Summersay415 commented May 18, 2024

This is intended behaviour. Default multiplayer peer is OfflineMultiplayerPeer, which mimics server. You can set multiplayer.multiplayer_peer to null to get error instead.

@AThousandShips
Copy link
Member

This is documented here but should probably be mentioned elsewhere as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants