Best possible shooting algorithm for Blueprints?
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?
asked Mar 22 '19 at 11:10 PM in Blueprint Scripting
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.
answered Mar 23 '19 at 05:04 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here