Announcement

Collapse
No announcement yet.

Automatic fire input over network

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Automatic fire input over network

    Does anyone have a good pattern for implementing automatic (like a machine gun) fire input in a networked scenario?

    I understand how to perform basic input in an authoritative client/server environment but this use case requires signalling the server to start and stop firing from the client side with a little more robustness. My initial solution was very simple, 2 custom events called from Client to execute on the Server for StartFiring and StopFiring called from the Pressed and Released input action node respectively. While this works in the happy path scenario, things fall apart when you introduce edge-cases for example; exiting the turret while firing, player loses connection while firing, player killed while firing, etc.

    Preferably I'd prefer NOT to have to resort to an endless list of bespoke checks to see if the player is still present, alive, connected and firing(though if that's the only way then I guess I'll just have to accept it).

    #2
    You could also make a "break/stop" event that you call when you have one of these cases, which just runs the release path.
    Add some checks to make sure nothing crashes / fails when called.

    Comment


      #3
      Thanks, I'll give that a try.

      Comment


        #4
        Do not make start/stop events for network. What will happen is that firs firing player who disconnects will keep firing. Or any lag and everybody will keep firing. Well that is your choice, kinda here.

        Instead i created "I keep Firing" event. It uses enumerator to tell server what is going on. Enum has just 3 values: "First fire", "Keep Firing" "Fire End". I call that event ever 0.2 sec.
        Now if server does not get "I keep Firing" for more than 1 sec it assumes client lagged or disconnected, and stops firing on that character.

        Now each weapon has mode of firing "Single shot", "Autofire" "Continous" (for eg flamethrower).
        Server checks what type of shoot it is, and what type of weapon it has.
        Then sends corresponding autofire events to weapon (that event is on different timers than "I keep Firing").

        So basically i have 2 parts of fire logic here:
        - first part is to tell if client continues to fire, when he starts and ends it.
        - second part handles autofire, and weapon fire types.


        I also packed it all to blueprintable component. Parent needs to have "Fire Now" interface with function that handles actual gun fire event.
        Then i just drop that component on all that fires, and implement "Fire now" function in it. Component keeps all data like autofire delay, ammo in gun etc.

        Comment


          #5
          Doh! Forums, Y U NO notify me of responses.

          Thanks Nawrot, I'll take look into that, sounds like a clean solution to achieve exactly what I'm after. Nice one!

          Comment

          Working...
          X