OnCollisionEnter on server only?
chr
✭
in Photon Bolt
Right now I have an OnCollisionEnter function on many entities which all start with
Is there a way to only have the function on the server? Am I wasting my time trying to optimize something that is not actually expensive? (I might have this on up to 50 entities at a time)
if (!BoltNetwork.isServer) return;
Is there a way to only have the function on the server? Am I wasting my time trying to optimize something that is not actually expensive? (I might have this on up to 50 entities at a time)
0
Comments
-
That's the way to do it. Bolt Physics are also server only and have lag compensation if you want to use them.0
-
what you are doing is correct.
you can also do
private void Awake()
{
if(BoltNetwork.isClient) { Destroy(this); }
}
to remove a script that you only want running on the server0 -
@dmg: Exactly what I need. Thanks
@stanchion: Is Bolt Physics something special or is it just running all physics on the server? And by lag compensation do you mean interpolation/extrapolation?
Sidenote: A little googling told me that running OnCollisionEnter is only expensive if you add the Collision object parameter, since Unity then has to create and calculate its values.0 -
Interpolation/extrapolation is client side prediction, Bolt physics is different. When you shoot other players in the tutorial it uses Bolt physics0
-
@stanchion: From what I can see in the advanced tutorial (part 5 - authoritative lag compensated shooting) nothing special is going on physics-wise. In the DisplayEffects function a normal Unity raycast is used. It even seems DisplayEffects is running locally. Am I missing something?0
-
@stanchion I found BoltNetwork.RaycastAll and BoltPhysicsHit hidden in the API. Can't find it elsewhere. Do you know how the lag compensation works?
Edit: nvm, it's in the sample project when downloading a newer version of Bolt0 -
Yup, Keep in mind you will need to estimate the playercamera distance and everything to accurately create a raycast on the server.0
-
Bolt raycast is lag compensated which means if a shot is fired 0.1 seconds ago and would've hit if the player was where he was 0.1 seconds ago, then it hits the player
https://developer.valvesoftware.com/wiki/Source_Multiplayer_Networking0 -
@stanchion That makes sense. Thanks!0