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

feat: Single player hosting in WebGL using RPC #3035

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

BenHamrick
Copy link

Expose the ability to use RPC especially on WebGL to allow us to easily make a single player mode while still using netcode usually as a host.

Changelog

  • Added: The ability to use RPC using a property in the Transport.
  • Changed: Allowed the ability to host a game if using RPC in WebGL to allow us to easily create a single player mode.

Testing and Documentation

  • No tests have been added.
  • No documentation changes or additions were necessary.

…ly make a single player mode while still using netcode usually as a host.
@BenHamrick BenHamrick requested a review from a team as a code owner August 27, 2024 04:53
@BenHamrick BenHamrick changed the title Single player hosting in WebGL using RPC feat: Single player hosting in WebGL using RPC Aug 27, 2024
@CodeSmile-0000011110110111
Copy link

CodeSmile-0000011110110111 commented Sep 24, 2024

@BenHamrick Where is the RPCNetworkInterface type defined? I tried to add this change but cannot find such a class in the entire codebase, not even in your fork, and not on the Internet at large.

@BenHamrick
Copy link
Author

@BenHamrick Where is the RPCNetworkInterface type defined? I tried to add this change but cannot find such a class in the entire codebase, not even in your fork, and not on the Internet at large.

My bad! It's supposed to be IPCNetworkInterface

@NoelStephensUnity
Copy link
Collaborator

@BenHamrick
You can opt to assign or create your own NetworkTransport that you switch to when running in a single player mode. You can make that implementation a "mock transport". You can see an example of a mock transport here.
Since you don't need any network connectivity in single player (other than services possibly which doesn't use UTP), all netcode related scripts should work. If you feel that this is not enough could you provide a working example for this PR so we can review it?

@BenHamrick
Copy link
Author

BenHamrick commented Jan 8, 2025

@NoelStephensUnity I tried using the mock transport but it seems like NetworkManager.RealTimeProvider is private so the script won't work as is. Also seems a little extreme to require me to make a whole new transport to run my game in single player. Is there maybe a more complete example somewhere I can use without the private reference? I also fixed this branch to work now.

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

Successfully merging this pull request may close these issues.

3 participants