x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

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?

Product Version: UE 4.21
Tags:
more ▼

asked Mar 22 '19 at 11:10 PM in Blueprint Scripting

avatar image

Plzwork1234
64 4 6 9

avatar image Nebula Games Inc Mar 23 '19 at 02:34 PM

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.

avatar image Plzwork1234 Mar 23 '19 at 05:36 PM

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++?

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Hi Plzwork1234.

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.

more ▼

answered Mar 23 '19 at 05:04 PM

avatar image

Alekann01
441 4 5 6

avatar image Plzwork1234 Mar 23 '19 at 05:47 PM

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.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question