Syncing Rotating & multiple Projectiles

Greetings, I have a projectile that actually consist of 3 colliders with a single parent rigidbody. The rigidbody has an angular velocity, when one of the triggers collide, the object with that trigger explodes and gets destroyed.

c7a393d3194fef7c037a8527c18f9260.gif

Now, the problem here is that, on some clients, some clients will see all the projectiles explode and some will only see 1 explode or 2 of them explode whilst the remaining projectile still follows through. So what's the best option for doing this?

Cheers in advance

Comments

  • Physics and networking are a tough problem. The results depend on timing and precision and even if the start is the same, the result might be slightly different per platform / device. It sounds so easy but with varying lag, things become really tricky.

    You need to sync the result per collider. The problem is: When it actually collided, there is no time left to sync this through network. The others would need the info instantly.
    In best case, one client decides if a collider hits anything before it gets visualized. If it collides, there has to be a message to the others asap that the projectile hit something and that X projectile parts are still going. In best case, you send the position where the projectile explodes.

    This makes one client responsible for the hits. The others will show an explosion as soon as possible. If the explosion is a bit bigger than the projectile, you can cover the exact position where the explosion was. Even if the local simulation moved the projectile a bit further than the explosion point, you might get away with it.

    Keep in mind that your players won't sit next to each other and compare everything for correctness. Try to hide some lag but most likely you don't have to worry how precise everything is.


    Let us know what you implement and how you approach the topic.
  • I placed a PhotonView component on each collider gameobject and the parent gameobject.
    I made a variable in the parent gameobject called "ChildCount" and set it to 3.
    When it collides, it sends an RPC to disable the collider, the renderer then ChildCount-- in the parent.
    In the Parent gameobject, when the childcount is 0, it gets destroyed.
    I managed to test this in a 3 player game just now, and it seemed to work without issues.
    Cheers for the help Tobias :)
Sign In or Register to comment.