multiplayer games

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
wumeng
Posts: 2
Joined: Sun Apr 21, 2024 8:47 am

multiplayer games

Post by wumeng »

In many cases, you can simply maintain the Dialogue System environment (including quests) in each client for each player.

In multiplayer games, how can I maintain a dialogue system environment for each player in each client? Can someone tell me what to do?
User avatar
Tony Li
Posts: 20677
Joined: Thu Jul 18, 2013 1:27 pm

Re: multiplayer games

Post by Tony Li »

Hi,

In a client/server multiplayer game, a server program will run on the server. Each player will run a client program on their own device. In many games, one player acts as the host, in which case they run a single program that runs as the server and their own local client.

Run the Dialogue System in the client program. This means all of the Dialogue System's data will exist only locally on each client. If you need to synchronize Dialogue System variables across multiple clients, you can use the LuaNetworkCommands script as a starting template to write your code. (If you're using Mirror, you can use the script as-is.)

If each playthrough is separate, such as in a battle royale game, you don't need to save data between playthroughs, so you don't need to do anything extra.

If the host can save the game and resume it later, you will need to save each client's data. To do that, on each client you can call PersistentDataManager.GetSaveData() to save the client's Dialogue System variables and quest states. Then send it to the server so the server can save it. When resuming a game, the server can retrieve the saved data, send it back to the client, and then the client can use PersistentDataManager.ApplySaveData() to apply it back into the client's Dialogue System.
wumeng
Posts: 2
Joined: Sun Apr 21, 2024 8:47 am

Re: multiplayer games

Post by wumeng »

In multiplayer games, what should the start conversation actor be filled in on the event trigger component of NPC objects?
Also, events on the player's Dialogue System events component can take effect when there is only one player, but they will not take effect when there are multiple players. Does anyone know how to solve this problem? Thank you.
Attachments
2.png
2.png (182.69 KiB) Viewed 21 times
1.png
1.png (173.08 KiB) Viewed 21 times
User avatar
Tony Li
Posts: 20677
Joined: Thu Jul 18, 2013 1:27 pm

Re: multiplayer games

Post by Tony Li »

Hi,

Since the Dialogue System will run locally on each player's device, use the same "Player" actor when writing your conversations.

Leave the Dialogue System Trigger's Conversation Actor field unassigned.

When the local player GameObject interacts with the NPC, the Dialogue System Trigger will use the local player GameObject as the Conversation Actor since that's what interacted with the NPC. For more info, please see Character GameObject Assignments.

Dialogue System Events components will only run on the Dialogue Manager GameObject and the conversation's primary participants -- in other words, the NPC and whichever player GameObject "used" the Dialogue System Trigger.
Post Reply