I just converted my current system to be replicated and it is very choppy and wonky. So it has me thinking. All the tutorials and different ways I’ve seen a gun shooting system implemented: what is the absolute best algorithm for gun shooting in Blueprints? Most efficient (FOR BLUEPRINTS), especially with replication in mind. There has to be a consensus on a certain way that is generally the best.
To make this easier to answer, at the very least what shooting foundation is the best to start with: a timer, a for/foreach/dowhile loop, just a looping branch with on/off conditions?
I 100% understand C++ is more efficient. But im looking at it like this: if i can convert the most efficient Blueprint algorithm to C++, it would be off the charts in terms of efficiency.
So does anyone have a system that’s worked well for them, or know of one?
If you can convert blueprints to C++ why not just start in C++ and make something as efficient as possible from the start? Also I don’t think there is a general consensus on a shooting algorithm. It depends on your situation otherwise it would be part of a library or something. Every game is different and has different needs which call for different code.
What is important to remember in replicated scenarios is server is king!
There isn’t a “perfect” algorithm for replication since your code should be tailored for each object. Some actors you will want to use natural replication for visual appearance, but other objects you can fake replication to save stress on the server.
When working with networked applications (especially with VR), I would code my objects so they handle themselves. All triggers should activate on the server and then inform clients that they should update. This is best handled with the correct uses of GameStates and PlayerStates since the information stored in these classes should be accessible by all entities in the world.
For shooting a gun, I would use something like this:
[Pawn Client] Left click input event: Trigger server event to fire the gun.
[Pawn Server] Spawn projectile (which uses natural replication) to travel across to map.
[Projectile Server] Fire overlap/hit events on the clients to trigger any terrain/world object changes.
[Projectile Server] Fire overlap/hit events which are multicasts (executes on server/clients) to handle hitting/killing a player.
Again, there is no such thing as a perfect solution. I would recommend you checking out RoboRecall from the market place (free), they use about 3 different methods for replication. I have to admit, their blueprints/code isn’t the cleanest. But it is a good project to strip apart.
well I’m heavily considering it at this point. I just havent learned C++ yet. I was trying to do a majority of this project in Blueprints then try and convert it to C++ as a way to learn it. I just figured there was at least a very general way its done. So maybe It was better to ask, how is it generally done in C++?
Thanks for the reply. I definitely get that there isnt a system that is exact, node for node. There has to be a little difference in the way a shooting system would be implemented project to project. I was just trying to see if there was even a base structure (timer, for loop, whatever) that was commonly used. Cause were talking about repeatedly crunching a huge string of code one after another with a gap of less than .1 seconds between each fire. I dont know if a timer handles that better, or just a branch looped to itself with a delay? Thats what im trying to figure out.