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 not supported #27

Open
Vaei opened this issue Jan 18, 2024 · 4 comments
Open

Multiplayer not supported #27

Vaei opened this issue Jan 18, 2024 · 4 comments

Comments

@Vaei
Copy link

Vaei commented Jan 18, 2024

I added Cog to the gamestate as per the example project and setup readme.

This means that BeginPlay, Tick, EndPlay are called for the server and every client. Of course, if I move it to GameMode, then it will only run on server and clients won't get any UI, so that won't help.

There seems to be a lack of consideration for the static properties that ImGui uses.

Soon as there is a server and a client (vs. standalone), it will crash on EndPlay because calling CogWindowManager->Shutdown(); shuts down the Context, causing ImGuiIO& IO = ImGui::GetIO(); to return nullptr, but it is not null checked (rather, it has an assert, which it fails, and then promptly crashes).

Furthermore, BeginPlay spams warnings because it is repeating logic:

Warning      LogConsoleManager         Console object named 'Cog.ToggleSelectionMode' already exists but is being registered again, but we weren't expected it to be! (FConsoleManager::AddConsoleObject)
Warning      LogConsoleManager         Console object named 'Cog.ToggleInput' already exists but is being registered again, but we weren't expected it to be! (FConsoleManager::AddConsoleObject)
Warning      LogConsoleManager         Console object named 'Cog.ResetLayout' already exists but is being registered again, but we weren't expected it to be! (FConsoleManager::AddConsoleObject)
Warning      LogConsoleManager         Console object named 'Cog.LoadLayout' already exists but is being registered again, but we weren't expected it to be! (FConsoleManager::AddConsoleObject)
Warning      LogConsoleManager         Console object named 'Cog.SaveLayout' already exists but is being registered again, but we weren't expected it to be! (FConsoleManager::AddConsoleObject)

Even if I test if ImGui has already initialized, to ensure it only runs once, then it'll run on the server and not the clients so they don't get windows.

For cog to support multiplayer (literally at all) it needs to respect that ImGui uses statics and separate out of the behaviour between Cog and ImGui so that you can initialize or clean up without making repeated calls to statics (especially when they are getting nulled).

This isn't sufficient on it's own, because we need to know when all clients have finished cleaning up, and then shutdown ImGui.

@arnaud-jamin
Copy link
Owner

Hello,

I will have a look. The reason I don't get this error on my side is because I do not use the unreal option "Run Under One Process".

If you uncheck this, Unreal spawn a process for the server and the client. This is more reliable since it is closer to what the players will experience.

@Vaei
Copy link
Author

Vaei commented Jan 22, 2024

I'm aware of the option but for rapid iteration and testing, it takes a lot longer to spin up so not a good option all of the time.

@arnaud-jamin
Copy link
Owner

Sure, that's why I'll have a look to fix it.

@Moniz
Copy link

Moniz commented Nov 21, 2024

I've got a fork that supports this now, if that's of interest
https://github.com/Moniz/Cog
Gamepad support is off for the moment though as I refactored how input is handled quite a bit

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

No branches or pull requests

3 participants