Fast collisions with Photon Rigidbodys (Golf game)

I am working on a networked golf game and trying to add collision between the balls. Each player has a ball prefab with Photon components like so: https://imgur.com/VrP10Jc

As it is right now, the balls often don't register a collision when they are moving too fast, although they register fine for slower collisions. Is there any other setting that can help me register fast collisions?

An alternative is to have the master client own all the balls and simulate all the movement. However, that's not very smooth from the player's perspective because every time they hit their ball, they might have to wait 100-200 ms to see it actually move.

Any ideas welcome!

Comments

  • I could increase the send rate but that might be a bad idea.
  • And if the answer is "You just have to do it on a master client"... I would appreciate some basic tips on that.
  • Each player has its own Golfball? So the balls are just syncd over the network,means u only sync position , the collision detection should hapen on the owner side.
    What you are locking for is https://docs.unity3d.com/ScriptReference/Rigidbody-collisionDetectionMode.html
  • Hi S_Oliver,

    The balls are all set to Continuous Dynamic. The physics itself works, it's definitely a network problem. When the balls move too quickly, the Photon Rigidbody View doesn't register a collision.
  • S_OliverS_Oliver ✭✭
    edited August 2018
    The Rigidbody View itself only Sync the Velocity, it dont detect Collision.

    Try the same Offline, use only the Rigidbody and see what happen.

    http://doc-api.photonengine.com/en/PUN/current/class_photon_rigidbody_view.html#details
  • Thanks for the reply.

    So I did try the collision offline, and the collision itself works locally, even with very fast movement.

    Now I see that the Rigidbody View only syncs velocity. If I wanted to detect a collision over the network, how should I do so?
  • Bumping my thread. Any suggestions for collision detection over the network, as the Rigidbody Views aren't really for that purpose? Should I go for a model with an authoritative master client or not? Open to any ideas!
  • Still open to any ideas!
  • Still open to any ideas!
  • STILL open to any ideas! Not sure why I've been trolled... Great customer support
  • sah1234sah1234
    edited August 15
    For the annals of history, collision detection is done through a custom rpc setup. Not perfect but definitely fine for this use case.

    void OnCollisionEnter(Collision collision)
    {
    if (!photonView.IsMine)
    return;

    Collider other = collision.collider;

    if (other.tag != "PlayerBallNetwork")
    return;

    Vector3 otherVelocity = other.attachedRigidbody.velocity;

    //Set other velocity
    PhotonView otherPhotonView = other.transform.root.GetComponent();
    Player otherPlayer = otherPhotonView.Owner;
    otherPhotonView.RPC("SetVelocity", otherPlayer, otherVelocity);
    }

    [PunRPC]
    void SetVelocity(Vector3 velocity)
    {
    rb.WakeUp();
    rb.velocity = Vector3.zero;
    rb.AddForce(100 * velocity); //Change this for more forceful collisions
    }
Sign In or Register to comment.