Best way to handle bullet respawns in a multiplayer 2d Platformer shooter?

Options
Hi guys i'm new to the forum, started using Photon 2 weeks ago, i love it.
This is my first multiplayer game, i know it might be too much to start with, but i wanted to give it a shot.
In my game, i might have around 10-15 players in the same lobby so you guess the amount of bullets will be kinda huge.

So instantiating them through PhotonNetwork.Instantiate is not the best choice for this. I saw you suggested using a Pool.
Checked @jeanfabre 's tutorial, but the problem is SimplePool isn't available anymore :(

How can I handle this bullet pool? Any suggestions?

Also, i read somewhere that the best way to display the bullets to everyone isn't by doing an instantiate through RPC but passing the coords of the bullet and that's all.

This is the way i'm spawning the bullets right now, without a pool:

private void Shooting()
{
if (Input.GetButtonDown("Fire1")) {
bool _usePrefabPool = true;
if (mySpriteRenderer.flipX == false) {
PhotonNetwork.Instantiate(bulletPrefab.name, new Vector2(transform.position.x, transform.position.y), Quaternion.identity, 0);
} else {
GameObject obj = PhotonNetwork.Instantiate(bulletPrefab.name, new Vector2(transform.position.x, transform.position.y), Quaternion.identity, 0);

obj.GetComponent().RPC("ChangeDirection_Left", PhotonTargets.All);
}
}
}

Thanks in advance!

Comments

  • jeanfabre
    Options
    Hi,

    The pooling principle applies, I w0ould simply replace the simplePool lines with what ever pooling solution you are going to use, I give another example with PoolManager5.

    else, let me know which solution you use, I'll check what would be the code for that solution.

    you can have lots of people in the lobby, it doesn't count as they are in rooms playing, what matters is how many players are playing in the same room, then firing bullets needs to be monitored.

    yes, spawning bullets are network object is a bad ideas, if bullets are fired at high rates. prefer indeed an RPC call, where each client instantiate a regular Object.

    however, for fast pace gameplay and bullet types gameplay, maybe Bolt is more suitable, as pun will have your objects synchronized over the network without a server, so you won't be able to to reliably check if you hit or not because of the synchronization, so I would also check out bolt, which has features specifically designed for this.

    Bye,

    Jean
  • msqar
    Options
    Thanks for replying Jean! i ended up going for Raycast bullets... starting to look on some tutorials.. i think that's better for a shooter instead of creating so many bullets... although, in the tutorial i'm watching, it is still instantiating a bullet Line Renderer 2D to simulate the bullet, and then the RayCast to collide with the players.. so i guess i might have the same issue without a Pool here?
  • msqar
    Options
    Okay so i got it working using a simple pool with RPC and Raycasting!