Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Third Party [PhotonPUN]Bullet Collision Problem

Discussion in 'Multiplayer' started by bekiryanik, Jan 27, 2016.

  1. bekiryanik


    Jul 6, 2014

    I am working on a 2D multiplayer game. Right now i am trying to collide the bullet with the player but whatever i did, i couldn't reach the success with it. I have searched a lot but i couldn't find a solution. What should i do to collide it?

    Here is some codes that i use:
    Code (csharp):
    2. void OnTriggerEnter2D(Collider2D other) {
    4. if ( == "networkPlayer")
    5.  {
    6.     Debug.Log("Colliding!");
    7.  }
    8.  }
    By the way, i have rigidbody2D and boxcollider2D attached on bullet and i set the trigger true.

    Here is what i use to create bullet:
    Code (csharp):
    2. GameObject bullet = PhotonNetwork.Instantiate("bulletRedSilver", newVector3 (transform.localPosition.x,transform.localPosition.y), transform.rotation, 0);
    3. if(photonView.isMine)
    4.  {
    5. = "myBullet";
    6.    bullet.gameObject.GetComponent<bulletScript>().enabled = true;
    7.  }else
    8. = "enemyBullet";
    And i attached PhotonView to bullet. When i launched it, it seems on the screen but it doesn't collide.