distinguish players for collision between them

Hi, i need distinguish player in network because i´m comparing their sizes and i need collision between them like this:

playersCurrSize = player.transform.localScale.x;
            collObjCurrSize = coll.gameObject.transform.localScale.x;


            if (playersCurrSize < collObjCurrSize) {

               
                Destroy (player);
                BackToMenu ();
            }

            else if (playersCurrSize > collObjCurrSize)
            {
                player.transform.localScale = new Vector3 (transform.localScale.x + (coll.gameObject.transform.localScale.x), transform.localScale.y + (coll.gameObject.transform.localScale.y)
                    , transform.localScale.z);
                Destroy (coll.gameObject);
            }

But when come collision in first case and Destroy(player) it destroys both players.

up

Well, if one’s smaller than the other…

On player 1’s end, that’s the case.
On player 2’s end however, guess what? it’s the other way around; the sizes relative to player 2’s end show that player 1’s bigger.

The upshoot is that on player 1’s end, the first if triggers, but on player 2’s end, the second if triggers. Likewise, both players end up nuked… What exactly are you trying to do? :smile:

If all you’re trying to do is figure out which player’s which… that might require a dedicated server in between, as P2P can get a bit messy.

I´m trying make game similiar agar.io … i need compare which player is bigger and bigger player “eats” the smaller player.

Ah, I see. In that case, for the smaller player, don’t have the smaller player call destroy on the other player. Rather, have only one callback to see if player 1 is bigger than player 2 and vice versa.

EDIT: Pseudocode to explain it:

if player1 > player2
increase size.
if player1 < player2
destroy yourself, and declare game over.

Thanks. This working but only if are connected two players - host and client. If connects the next player and kills other client. It kills everybody :smile:

Um… wut? XD That should work regardless of number of players…
Maybe a basic stripped-down example could be uploaded? I can try having a fiddle when I get time. :slight_smile:
I got similar mechanics working (not involving two players though, it was between a bullet and a player) in some experimental shooter I made to try out the old networking, UNET can’t be that different to it, surely…

EDIT: Oh wait, so you’re saying a HOST (client + internal server) leaving or disconnecting kills the lot? That’s actually normal for both UNET and the old system; as soon as the server’s gone, it nukes everyone else.

A workaround obviously is to have a separate server running somewhere else.

Okay, whith some miracle it works. But if client destroys other client, the destroyed client destroys yourself in client´s game who destroyed him but in his game he is not destroyed and can play on. If you want help me, i can upload project and send you it.