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: void OnCollisionEnter2D(Collision2D coll) { if (!isLocalPlayer) { return; } playersCurrSize = player.transform.localScale.x; collObjCurrSize = coll.gameObject.transform.localScale.x; if (playersCurrSize < collObjCurrSize) { Debug.Log ("Player is smaller"); 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. It´s multiplayer with using Unet.
I'm new to Unity so this idea might be absolute trash. But by looking at the code and the effect you want to have I would try using tags on your players to define each one. So that you could use something like`if (tag == Player/otherPlayer) Destroy(Player);.` $$anonymous$$aybe?
Yes, i tried this but problem is in Destroy(Player), because you have same tag on player and other player too.