It's common to lead private functions and variables with an underscore to mark them as such, for example: "_shoot()", it's still public on a technical level though (you can manually call _shoot even from outside the object, even if it has a leading underscore) but its still nice practice
Wondering what would be the best approach for a PvE type game, Like handling spawns and sync of enemies and how to do it in a way that doesn't consume a lot of bandwith. Loving the series btw
That’s a good idea! I’ll make a part 5 that’ll cover enemies. Right now I want to focus on implementing NAT punch through so the game is actually playable with friends, but after that, I’ll dive into enemies. Off the top of my head, I’d say have the “hosting” player handle spawning the enemies. Depending on the number of enemies, it would probably be alright to use the MultiplayerSynchronizer and sync the positions. If there’s going to be a lot of enemies, you could synchronize the enemy targets and let the clients calculate the movement instead.
I tried the fix for the last error, making apply_damage func an rpc, but it didn't make the fix and now I'm getting "RPC 'apply_damage' on yourself is not allowed by selected mode." Great video btw!
Make sure you’re using body.take_damage.rpc(25) instead of body.take_damage(25) Also make sure the take_damage function has the “any_peer” tag. If both of those are correct, you can try adding the “call_local” tag to the take_damage function
@@Bond01_ Absolutely! I’m going to make another more in depth multiplayer series in the future, I’m kinda waiting to see when Godot 4.4 will come out that way it’ll be up to date
Love the series, new to multiplayer but great way to structure the format with out unnecessary long videos. A general question, if instead of destroying the bullet or smililar on each client as a call from the server. Could we not instead let each client handle the destruction even if it does not have multiplayer authority and simply do that for the damage. To minimize data transfer. (bullet.gd, row 8) Or would that generally be used for exploitation and it's a better choice to let it be managed by the server? I do understand that this can be diffrent for each game depending on each exact function and the wanted outcome, but im just curious from your point of view. (Hopefully you don't take this as backseat programming, video was great i just want to learn how to approach diffrent functionalities when it comes to MP)
@@dnlci Great question! Obviously there’s a million different ways to go about it. In my case, I chose to have the peer who shot the bullet handle collisions, spawning, and deletion, while letting all other peers handle movement. The reason I didn’t let each peer handle deleting the bullet is because of latency. Let’s say Player 1 shoots a bullet. P1 will see the bullet immediately, while P2 will have a slight network delay. Since the bullet should immediately start moving forward after being spawned in, the bullet that P2 sees may end up being slightly behind what P1 sees. If we let each peer handle deletion, there’s a chance that P2 could accidentally delete a bullet that is still visible on P1. The case that this happens is pretty slim, but I prefer to have as much consistency as possible. One RPC to delete the bullet won’t have a large effect on bandwidth. That being said, I don’t see any serious issues with letting all peers handle deletion. With either setup, there’s going to be an occasional “DUDE THAT BULLET DIDNT HIT ME”. Just make sure there’s only one peer handling dealing damage. In P2P games, exploitation shouldn’t be a priority. It’s pretty easy to exploit the game since the peers are all talking to each other, rather than talking to a dedicated server that can verify information.
for some reason if I host i can shoot but as soon as another player join, when I shoot THEY shoot (and I dont) but if THEY shoot thay can't. like my Muzzle switched to new player. How this can be fixed? Also how to fix new player cant' shooting?
I wanted to move shooting code into weapon itself (so later i could make more different weapons) but it is not working, so I followed your tutorial and it work perfectly, but only one weapon type
It sounds like an authority issue. In your weapon script, are you making sure that client has authority over the node before getting input? You’ll need a line like this before you get input: if !is_multiplayer_authority(): return
It's common to lead private functions and variables with an underscore to mark them as such, for example: "_shoot()", it's still public on a technical level though (you can manually call _shoot even from outside the object, even if it has a leading underscore) but its still nice practice
thank you very much
Wondering what would be the best approach for a PvE type game, Like handling spawns and sync of enemies and how to do it in a way that doesn't consume a lot of bandwith. Loving the series btw
That’s a good idea! I’ll make a part 5 that’ll cover enemies. Right now I want to focus on implementing NAT punch through so the game is actually playable with friends, but after that, I’ll dive into enemies.
Off the top of my head, I’d say have the “hosting” player handle spawning the enemies. Depending on the number of enemies, it would probably be alright to use the MultiplayerSynchronizer and sync the positions. If there’s going to be a lot of enemies, you could synchronize the enemy targets and let the clients calculate the movement instead.
@@curtjs-dev Awesome! Thanks for the help. Looking forward to the new episodes!
I tried the fix for the last error, making apply_damage func an rpc, but it didn't make the fix and now I'm getting "RPC 'apply_damage' on yourself is not allowed by selected mode." Great video btw!
Make sure you’re using body.take_damage.rpc(25) instead of body.take_damage(25)
Also make sure the take_damage function has the “any_peer” tag.
If both of those are correct, you can try adding the “call_local” tag to the take_damage function
very nice, would love to see some sort of matchmaking and sessions list system, is that possible?
@@Bond01_ Absolutely! I’m going to make another more in depth multiplayer series in the future, I’m kinda waiting to see when Godot 4.4 will come out that way it’ll be up to date
Love the series, new to multiplayer but great way to structure the format with out unnecessary long videos.
A general question, if instead of destroying the bullet or smililar on each client as a call from the server.
Could we not instead let each client handle the destruction even if it does not have multiplayer authority and simply do that for the damage.
To minimize data transfer. (bullet.gd, row 8)
Or would that generally be used for exploitation and it's a better choice to let it be managed by the server?
I do understand that this can be diffrent for each game depending on each exact function and the wanted outcome, but im just curious from your point of view.
(Hopefully you don't take this as backseat programming, video was great i just want to learn how to approach diffrent functionalities when it comes to MP)
@@dnlci Great question! Obviously there’s a million different ways to go about it.
In my case, I chose to have the peer who shot the bullet handle collisions, spawning, and deletion, while letting all other peers handle movement. The reason I didn’t let each peer handle deleting the bullet is because of latency.
Let’s say Player 1 shoots a bullet. P1 will see the bullet immediately, while P2 will have a slight network delay. Since the bullet should immediately start moving forward after being spawned in, the bullet that P2 sees may end up being slightly behind what P1 sees.
If we let each peer handle deletion, there’s a chance that P2 could accidentally delete a bullet that is still visible on P1. The case that this happens is pretty slim, but I prefer to have as much consistency as possible. One RPC to delete the bullet won’t have a large effect on bandwidth.
That being said, I don’t see any serious issues with letting all peers handle deletion. With either setup, there’s going to be an occasional “DUDE THAT BULLET DIDNT HIT ME”. Just make sure there’s only one peer handling dealing damage.
In P2P games, exploitation shouldn’t be a priority. It’s pretty easy to exploit the game since the peers are all talking to each other, rather than talking to a dedicated server that can verify information.
for some reason if I host i can shoot but as soon as another player join, when I shoot THEY shoot (and I dont) but if THEY shoot thay can't. like my Muzzle switched to new player. How this can be fixed? Also how to fix new player cant' shooting?
I wanted to move shooting code into weapon itself (so later i could make more different weapons) but it is not working, so I followed your tutorial and it work perfectly, but only one weapon type
It sounds like an authority issue. In your weapon script, are you making sure that client has authority over the node before getting input?
You’ll need a line like this before you get input:
if !is_multiplayer_authority(): return