Documentation on creating custom Dialogs

Hello everyone,

I recently came across Coherence and thought I’d give it a try as it looked interesting. Reminded me a lot of SpatialOS, but looks more promising.

A little bit of background as it may help with my question. I have experience with UNET, PUN 1 and 2, Mirror and MLAPI (before it was rebranded to Netcode for GameObjects).

Each of these allowed you to build a custom NetworkManager if you will so you can have control over when a connection starts, a room is created, a player joins, what to spawn, transition scenes, etc… moreover, it is a good way to understand how the networking flow works in the framework (at least for me).

For example in PUN 2, you can create a script and have callbacks for CreateLobby, OnLobbyCreated, CreateRoom, OnRoomCreated, OnPlayerSpawned, etc…

I am trying to find tutorials or documentation that explain these things but aside from a couple of methods I found here not much is explained on that topic. Even those methods seem to not flow (unless I misunderstood what is there).

To summarize, I just want to understand the flow from the minute my game starts and tries to connect to a replication server > create a room > join room > etc… so I can build a custom connection GUI that allows me to transition between a connection scene to game scene and spawn players and other objects as needed.

Thank you very much in advance.

Hello and welcome!

Sounds like you have a lot of experience across a wide range of multiplayer tools - thanks for trying coherence out. We’d love to hear how you think it stacks up.

I believe our samples and sample projects have all the info you’re looking for. Our sample connect dialogue uses our SDK to control conection flow, and the sample projects handle scene transitions etc:

Take a look at those and see if they have what you’re looking for.

Hey @Vallar! To add to what Brit suggests, we also have a simplified connection UI as part of our package samples: Package samples | coherence Documentation - included directly within the Unity SDK.

That might also be a good starting point to learn, as that UI is a bit simpler than the ones you can import from the coherence > Explore Samples window.

The scripts in this section might also help! coherence Cloud APIs | coherence Documentation

Let us know if you get stuck at a specific point.

Thank you @brit and @ciro for the links. I checked the prefab and it is a bit simpler than the one I imported from the SDK directly.

After waging through the sample code and the articles you linked, I was able to put together a replication of create, join and refresh. Great.

But I do have questions. First one, where do I provide feedback? Suggestions forum? Discord?

There are a few things that confuse me in the sample code:

So you have this code private IRoomsService selectedRoomService; and then private ReplicationServerRoomsService replicationServerRoomsService;

That is fine. Little down the line the sample has replicationServerRoomsService = new ReplicationServerRoomsService();

  1. What does that do? I understand it creates a new class instance, but what does that entail?

I am asking because a little later, the sample code has selectedRoomService = replicationServerRoomService, which further confused me.

  1. What is happening here? Moreover, I was more confused when I created my own connection GUI as mentioned above and I didn’t do any of that at all.

  2. Does this mean that this is only required for local? And potentially what I am missing to create/join/refresh rooms locally (i.e. running a local replication server)? If that is the case, then how does Coherence know that I’ve requested or are looking for one? Is it just the instance creation that does this?

  3. There are some variables that I don’t understand what they do for example take CoherenceBridge.IsConnected. Based on this, one would think this is related to connecting to the cloud service. But that wasn’t the case when I tested. So that means maybe this is for room connection?

  4. I read through This and it seems that to switch clients all I need to do is call CoherenceBridge.SetClientScene(x) excellent. Now the question, how do I spawn players? I searched with keywords like “spawn”, “Instantiate” and “Create” and I didn’t find anything in the API documentation inside CoherenceBridge. I did find this, which infers that setting this scene will automatically take care of instantiating players for each client. But where do I set the prefab to be instantiated?

Thank you very much in advance.

Great!

I think the best way would be on the Suggestions sub-forum. Then it would be properly archived, searchable, and we could have a follow-up discussion about it in there. Thanks :slight_smile:

I’ll field the UI-related questions in a second, I might have to ask the team (@brit?). But in the meantime, regarding this:

That page you found refers to where the Bridge will spawn remote entities for you. But that’s an advanced use case, it makes sense to look into it only if you have multiple scenes.

But for your local entities, the solution is actually super simple: you can spawn them from any script. Check out this page*: Instantiate and Destroy Objects | coherence Documentation

Does it make it clearer?

(*) The page is new and for now is only in our 1.4 version of the manual, which is not the default, but it will be soon.

@ciro thank you very much. I’ll compile my feedback in one thread and post it later once I have fully finished my implementation.

But for your local entities, the solution is actually super simple: you can spawn them from any script.

OK, so there is a 1.4, I thought 1.3 would be the latest, thank you for giving me the heads up. I’ll try to stick to 1.4 for documentation going forward. Does this mean there is an SDK v1.4 or that is still WIP? This explains quite a lot. Thank you.

One other question (hopefully, the last, I am sorry, really trying to keep the questions down), we’re working on a game similar to Spellbreak. I’ve seen documentation saying Coherence doesn’t support this kind of gameplay at the moment Determinism, Prediction and Rollback | coherence Documentation (I am referring to the FPS comment).
Yet, it seems in another part of the documentation it sounds like that kind of thing is supported Server-authoritative setup | coherence Documentation

Can you give me a definitive answer?

Note that we’re aiming for server-client architecture (since it is a competitive game) not host-clients or P2P.

Thank you very much in advance.

1 Like

coherence fully supports a server-authoritative setup: your simulator can have full authority over all client’s entities.

Your game’s prediction system will likely differ from the guide presented, as that GGPO guide is more suitable for something like a fighting game (and not an FPS like a Spellbreak type game).

Although we don’t have a guide up right now rest assured you can build a server authoritative game, and like any networking solution, your game’s prediction model will likely be very specific to your game feel!

Thank you very much for the clarification. I understood the part where it said GGPO isn’t suitable for FPS. The second part, saying that the feature will be available in the future, threw me off.

1.4 is still in the works, but will release soon. As a teaser, the only big new feature in 1.4 is that we will provide “ordered commands”, so the ability to send Network Commands and be sure that they will also be received in the same order (at the expense of performance, of course). So if they are not something that interests you, you’re not missing out for now :slight_smile:

And yeah, we generally “unveil” the docs for versions in the works but we don’t set them as default, so they usually contain new pages and tweaks. But we might rethink this mechanism, we’ll see.

Generally speaking, where that comment goes is that we don’t have, out of the box, tools for traditional FPS (think Call of Duty, Counterstrike), but it’s not impossible to make them yourself.

Great to hear that. Thank you very much.

Since you mentioned rolling my own prediction/reconciliation does Coherence provide any help there – like for example, does Coherence work with ticks? Or that is also under the “roll-your-own” part?

1 Like

Do you mean if coherence supports a fixed framerate simulation?

Do the pages under this category help? Competitive games | coherence Documentation

Yes, I should’ve rephrased the question better. But yeah, a way to sync time between the simulator and the client so I can use it to predict and reconcile. That page definitely helps, thank you very much.

1 Like