Announcement

Collapse
No announcement yet.

create damage when grenade explodes

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

    create damage when grenade explodes

    Hi peoples

    I have my grenade setup, launching and exploding. Just having issues getting it to damage enemies on explosion. Any advise on the best way to configure this in blueprints? I dont want the damage range to effect enemies differently, I just anything with a radius to be have health got to zero.

    Please any advise would be great.

    Adam

    #2
    It would depend on how your grenade works. Does it explode on impact or is it timed? How are you determining the radius of the grenade?


    This is just a sample - you can use a collision sphere to set the radius.

    Click image for larger version

Name:	GrenadeExample.png
Views:	324
Size:	496.6 KB
ID:	1730177

    Then however you have your grenade exploding, you would run a server event to get overlapping actors of whatever your player pawn's class is (mine is PP_Game in this instance) and iterate through and call the Apply Damage node.
    Click image for larger version

Name:	Kaboom.png
Views:	298
Size:	257.6 KB
ID:	1730178

    Then on your pawn you would use the Event AnyDamage node to do whatever you want with the damage (i.e. subtract it from health, show screen effect on client side, camera shake, etc.)
    Click image for larger version

Name:	PlayerDamage.png
Views:	296
Size:	133.0 KB
ID:	1730179

    Hope this helps
    UE4 Tutorials
    Multiplayer / Replication Series
    Discord Dilemmas Series

    Marketplace Assets
    The Perfect Storm

    Dynamic Radial Menu

    Comment


      #3
      Hi thanks so much for the detailed response. I am working through it now. I am using a timer for the explosion. I am also using the collision to determine the range so this is perfect. If i am taking 100 percent damage how would that change the Event Any Damage node setup. Just a little unsure about that last step...

      Cheers

      Comment


        #4
        The Apply Damage node takes a float for damage - not a percentage. If you want grenades to take 100% of the players health, you don't need the Apply Damage and Any Damage - you would just call a "KillPlayer" event or something instead that would simply kill the player if they got hit with a grenade. Hopefully that makes sense - sorry if I'm misunderstanding what you're asking.

        An actor can only have 1 single Any Damage node inside of the blueprint. So we're calling Apply Damage here from the Grenade passing in our Pawn as the Damaged Actor. The Pawn blueprint, if it has an Any Damage node implemented, will execute the Any Damage node and pull in the information from the Apply Damage node.

        Here's how the input pins on the Apply Damage correspond with the Any Damage node just as an FYI if you're interested. The Damage Type is a class you can set on the Apply Damage node which will instantiate and then pass a reference of that Damage Type to the player as well (purple pin on the Apply Damage node - which means it's a class reference and then it's a blue pin on the Any Damage node indicating that there's an object reference now that's been 'spawned' so-to-speak - realistically it's an actual instance of the Damage Type class).

        ^ All of that info might have been useless, but figured if you don't use this info, someone else in the future may


        This would be on your grenade actor.
        Click image for larger version

Name:	ApplyDamage.png
Views:	320
Size:	66.2 KB
ID:	1730199



        This would be on your pawn. So on your pawn you'd probably want some "Health" variable and you would subtract the damage from the health. Then you can use the grenade reference to say something like "Hey bud, you just nom-nom-nom'd a grenade!"
        Click image for larger version

Name:	AnyDamage.png
Views:	292
Size:	36.7 KB
ID:	1730200
        UE4 Tutorials
        Multiplayer / Replication Series
        Discord Dilemmas Series

        Marketplace Assets
        The Perfect Storm

        Dynamic Radial Menu

        Comment


          #5
          They are a dedicated damage Radius with more options

          Click image for larger version  Name:	grenadeDamage.JPG Views:	0 Size:	139.8 KB ID:	1730211

          if you wanna kill regardless of damage can create a damage type class


          btw, why you use a RPCs instead a has authority?
          Last edited by DomusLudus; 03-08-2020, 02:07 AM.

          Comment


            #6

            Originally posted by IIINAYLZ View Post
            ...I dont want the damage range to effect enemies differently, I just anything with a radius to be have health got to zero...
            DomusLudus the OP mentioned that he didn't care to do ranged damage - he just wanted to bring anyone's health within the blast radius to 0 (thanks for your response because it made me re-read his original post and realized I missed that last piece of setting health to 0).

            IIINAYLZ Apologies for misreading your original post. When your event timer triggers the explosion event, iterate through all the overlapping actors that are of type Pawn and set their health to 0


            Originally posted by DomusLudus View Post
            ...btw, why you use a RPCs instead a has authority?
            Switch has Authority is used because something is happening on the server side as well as the client side. I don't know how OP's logic is setup but the "KABOOM!" RPC you see in the image would be something that would only happen on the server side (if I was setting up my game that is) which would handle dealing the damage to the players. If you print string you would see that the event is only running on the server so the Switch has Authority's "Remote" output would never execute - the client is never running this "KABOOM!" RPC.

            At the end of the execution chain I would then call a Multicast that will handle telling all of the relevant clients to "play grenade visual explosion / sound / particle effects" etc. In theory, if I'm running on a dedicated server, sound, particle effects, etc. don't exist on a dedicated server so you can essentially use a Switch has Authority after the Multicast and only play the visuals/audio of the grenade on Remote (client) machines and your dedicated server does nothing more at that point - i.e. doesn't even try to run any more logic after your Multicast event is called.

            UE4 Tutorials
            Multiplayer / Replication Series
            Discord Dilemmas Series

            Marketplace Assets
            The Perfect Storm

            Dynamic Radial Menu

            Comment


              #7
              thanks again for the replies, still working through it and struggling a bit. will keep tweaking and post some screens if I cant work it from here.

              Comment

              Working...
              X