Managing Local multiplayer and Online Multiplayer
The whole answer can be found below.
Try Our
Documentation
Please check if you can find an answer in our extensive documentation on PUN.
Join Us
on Discord
Meet and talk to our staff and the entire Photon-Community via Discord.
Read More on
Stack Overflow
Find more information on Stack Overflow (for Circle members only).
Managing Local multiplayer and Online Multiplayer
Mark_V
2020-05-15 13:49:14
Hello All,
For a project I'm working on, which already has local (offline) multiplayer, I need to implement networking functionality. For this I'm using PUN. The networking part is not the problem here. After starting to work with the networking I found it difficult as to how to balance my scripts to work for both online and offline. For example, the player instantiation would work differently, but we would have the same basic player components.
I am not sure what would be a good way to keep the networking functionality in my scripts separate from the normal functionality as much as possible. I imagine that I would have to add checks in some scripts like: photonView.IsMine
Which is not really ideal in my situation.
I was wondering if anyone here has any experience on this subject, or some best practices type of advice.
Thanks!
Comments
Hi,
Basically seperate network related scripts. You could check on start PhotonNetwork.IsConnected. If it is then enable your networked scripts. Other ways you can keep them disabled. If you want to reach network scripts somewhere still you can check if that client connected photon. Btw I never tried before mix online and offline together. I wrote to give you an idea.