Need Advice on Weapon System Design

So, I am making a game with lots of different kinds of weapons and so lots of different kinds of bullet visuals. I am trying to decide between two different design approaches. (I have read the many posts on this topic, but I am still having trouble deciding.) Which option better?

Option 1: Add lengthy debounces (.1 to .5) before the player can fire the weapon again with a reloading animation and run the bullet visuals on the server. The gun local script just sends the (mouse.hit.p) and the server does the ray cast, creates the bullet visual, and assigns damage. The purpose of the long debounces, of course, is to avoid lag on the server. I could even add longer debounces if lagging became an issue. I could also limit the number of players on a server at a time.

This option has the advantage of simplicity, but I am concerned about the lag problem. At approximately what point would lagging become a problem? (I know that is impossible to answer without knowing anything else about the game, but any info would be helpful.)

Options 2: Run the bullet visual on the local script and then use a remote event to send to the server {player, weapon type, gun tip, mouse.hit.p}. Server runs a second ray cast (with no visual) and assigns damage and sends a remote event to all clients to create the visual effect from that player to the spot hit.

This seems to be the classic approach. It is more complicated and I am worried about the visual effects lagging behind a bit due to the remote events. Before a client (other than the player who fired the weapon) can see the bullet effect information has to be passed between two remote events and then the client’s computer has to actually create the visual. That is going to take some time. Is the advantage in terms of using less server power worth it? (Again, I know this is an impossible question with such limited info, but any ideas would help.)

Any advice that you have would be greatly appreciated. Thank you!

2 Likes

Option 2 is the way to go, you will never get the game to feel good if it doesn’t look instant to shoot. No idea what you mean by “lengthy debounces” for option 1 tho.

1 Like

A debounce before you can fire the weapon again. Thank you for your thoughts!

1 Like

That would also feel really bad and unresponsive, and is probably completely unnecessary. Don’t worry about performance issues from firing lots of bullets unless you know for sure that it’s a problem. If in doubt use the micro-profiler to see how long different computations actually take. If you do have to limit the amount of bullets fired per second, don’t do it with “debounces”, just limit the fire rate of weapons normally.

3 Likes

Option two is definitely the one you want. However, if your gunplay is relaxed - maybe you’re making a Napoleonic Era game with muskets and flintlocks etc. - I’d say go for option one. Players would be shooting every 15 seconds or so and unless you have more than 100 players, it shouldn’t be too laggy.

2 Likes

Should I use one remoteevent for all weapons or make different events for the different classes? Are there limits to how many players can use one RE at one time?

id say use different remote event for different classes so it is more organized and could easily add new guns

i believe there isn’t because it isn’t documented in the Roblox developer hub for remote events

Actually nevermind about what i said there isn’t any limit, there is a limit and it says around 50kbps based on this reply on a topic about asking the limit of remote event

1 Like

Okay, even if there are 50+ different weapon types an RE for each weapon type would probably be best. It seems less elegant, but there is no actual technical problem with lots and lots of REs. Thank you!

There is a rate-limit of I believe 20 Hz but I’ve fired remote events at 60 Hz. The bandwidth is 50kpbs (from each player), unless you’re sending novels through remote events you should have zero problem.

I think you should have a few remote events, maybe one for each class but make sure it doesn’t get very confusing.

2 Likes