Hi, I’m making a basic top down shooter game with Photon where players dual wield guns and I have an issue.In my bullet script I have a function which gives the shooting player a point if it kills the enemy.
When 2 bullets collide with the player at the same time and kill the player, point increases twice instead of once. I think it’s because both bullets trigger the score increase in the same frame but I don’t know how to get around it.
private void OnTriggerEnter2D(Collider2D collision)
{
if (!photonView.IsMine)
{
return;
}
PhotonView p = collision.gameObject.GetComponent<PhotonView>();
if (p != null && !p.IsMine)
{
if (p.CompareTag("Player"))
{
p.RPC("SetHealthBar", RpcTarget.All, damage);
if (collision.gameObject.GetComponent<HealthSystem>().fillingImage.fillAmount <= 0)
{
gM.killCount++;
}
}
Destroy(gameObject);
}
if (p.CompareTag("Obstacle")) //destroy on collision with obstacles
{
Destroy(gameObject);
}