InGame

Lecture Summary: InGame

In this lecture, we explored the concept of "InGame" in Unity's Netcode for Entities. This critical step allows us to move beyond just sending RPCs and enables the synchronization of constant data, such as transform positions, between the client and server.

We started by explaining that although our connection technically worked, it was limited to sending and receiving RPCs. To enable constant data synchronization, we needed to mark the connection as "InGame." The process involved setting up client and server systems that handle the transition to the InGame state.

On the client side, we created a system (GoInGameClientSystem) that adds the NetworkStreamInGame component when a connection exists. This change signals the client is ready for constant data synchronization. The client also sends an GoInGameRequestRpc to the server, notifying it to mark the connection as InGame.

On the server side, we built the GoInGameServerSystem to listen for the GoInGameRequestRpc. When received, the server added the NetworkStreamInGame component to the corresponding client connection entity, enabling bidirectional snapshot data synchronization.

After implementing both systems, we tested the connection, verified data was being sent and received in the NetworkConnection, and used the Network Debugger to confirm everything was working. With the connection fully established, we are now ready to build the game grid in the next lecture!

Complete and Continue  
Discussion

6 comments