(PhotonPUN) Where are all these messages coming from?!

I’m making an RTS game, and I found that with just a few dozen units my messages per second was approaching the informal limit of 500. So, as one is supposed to, I removed the PhotonTransformViews from the units, and replaced them with a sytem that attempts to carry out similar simultanious simulations on all clients. This involves calling a position-correcting RPC about once per second per unit, and a navigation RPC about once every two seconds for per unit. So, compared to the default transmission rate of a PhotonTransformView, which I think is ten updates per second, this should be, at most, a fifth of the original messaging rate, right? Wrong. It looks like my messages per second is more than twice as high as when I was using PhotonTransformViews, although data-usage is reduced to a third of what it formerly was.

What gives?! I did remember to make it so that my RPCs are only called when the object is actually moving, and I have been careful to run the same tests. Any insights would be appreciated.

-Aidan

The “secret” is that several PhotonView updates (via OnPhotonSerializeView) will be added to a single message, which makes the message count go down.
You can do the same or similar for RPCs.
Alternatively, if a PhotonView should not write each update, simply don’t add data to the PhotonStream in OnPhotonSerializeView. This will skip the object’s update but you don’t need to time your RPCs yourself.

@tobiass Thanks; I figured it was something like that. I’ve found that taking an even more hands-off approach, putting more faith in the simulation to work the same regardless of any floating-point shifts, has paid off. I’ve gotten rid of those position-update and navigation-update RPCs I mentioned, so my message rate is now under control.

1 Like

@tobiass Actually, things aren’t going as well as I thought. Maybe you have some suggestions?