Handdle Bolean in multiplayer

1
  • 0 favourites

Stats

36 visits, 43 views

Tools

License

This tutorial is licensed under CC BY 4.0. Please refer to the license text if you wish to reuse, share or remix the content contained within this tutorial.

I would like to share my technique for dealing with booleans in multiplayer.

Let's analyze the image below...

We then have a computer that shows whether it is on or off in all peers. If someone changes it, it changes for everyone.

The code is this below, let's understand why things are like this.

Line 73

Both the host and the peer can touch the "PC"

its boolean then remains ON and if it is a Host it will transmit this information through a message, if it is a peer it will also send the message to the host. (as the host does not receive its own message, that is why we change the boolean locally)

Line 74

The same thing, both one side and the other change the state of the pc and transmit their change notice to the host or the host to the peers.

Line 75

The message will be received by both the host and the peers and the boolean will then be changed.

Line 78 and 79

The change is made in the animation following the boolean.

I hope this helps to activate and deactivate things over the internet without wasting bandwidth using an "every tick". Furthermore, even one setbit would force the host to synchronize the variable all the time.

  • 0 Comments

  • Order by
Want to leave a comment? Login or Register an account!