// Update is called once per frame new void Update() { base.Update(); if (functional && photonView.isMine) { GameObject c = PhotonNetwork.Instantiate(mProtector.name, new Vector3(transform.position.x, transform.position.y, transform.position.z), Quaternion.identity, 0); //GameObject c = Instantiate(mProtector, new Vector3(transform.position.x, transform.position.y, transform.position.z), Quaternion.identity); protector p = c.GetComponent <protector>(); p.mPlayerId = mPlayerId; p.parentID = viewid; c.transform.parent = transform; functional = false; } }
void OnCollisionEnter2D(Collision2D collision) { if (collision.gameObject.CompareTag(GameConstants.Tags.cell)) { Debug.Log("Bullet hit by " + collision.gameObject.name); Physics2D.IgnoreCollision(mCollider, collision.collider); return; } GameObject collideObj = collision.gameObject; PhotonView pv = collideObj.GetComponent <PhotonView>(); if (!pv) { Debug.Log("Bullet hit by " + collision.gameObject.name); return; } bool isSamePlayer = pv.ownerId == photonView.ownerId; if (collision.gameObject.CompareTag(GameConstants.Tags.lily)) { Debug.Log("Bullet hit by lily" + collision.gameObject.name); BaseLily bl = collision.gameObject.GetComponent <BaseLily>(); if (isSamePlayer) { Physics2D.IgnoreCollision(mCollider, collision.collider); return; } if (photonView.isMine) { PhotonNetwork.Destroy(gameObject); } } else if (collision.gameObject.CompareTag(GameConstants.Tags.protector)) { Debug.Log("Bullet hit by protector" + collision.gameObject.name); protector p = collision.gameObject.GetComponent <protector>(); if (isSamePlayer) { Physics2D.IgnoreCollision(mCollider, collision.collider); return; } if (photonView.isMine) { PhotonNetwork.Destroy(gameObject); } } }