Hi ! I am making multiplayer shooter 2d game by photon.But for big distances collider doesn’t detect collision when bullet of player number1 shoot player number2,i use OnTriggerEnter2D for bullet and player prefabs.Have any suggestions?Thank you anyway!
Here is my part of code from player script:
public void OnTriggerEnter2D(Collider2D collision) {
if (collision.CompareTag("Bullet")) {
if (!collision.GetComponent<PhotonView>().IsMine) {
if (NameOnPlayer.clor == collision.GetComponent<SpriteRenderer>().color) {
PhotonNetwork.Destroy(this.gameObject);
res = true;
}
}
}
}
}
and bullet script:
public class bullet : MonoBehaviourPun {
public void OnTriggerEnter2D(Collider2D collision) {
if (collision.CompareTag("Player")) {
if (!collision.GetComponent<PhotonView>().IsMine) {
PhotonNetwork.Destroy(this.gameObject);
}
}
if (collision.CompareTag("wall")) { PhotonNetwork.Destroy(this.gameObject); }
}
}