Electro Spark - Damage Script

Unreal Engine 4: Character Skill System Black Magic - Electro Spark
6 minutes
Share the link to this page
Copied
  Completed
In this video, we'll create script inside of our Electro Spark Blueprint that'll send the message to cause damage to actors that it hits.

Transcript

Welcome back everyone one more video here in our electro spark series of videos. Our goal in this one is to write some script that will cause damage to any actor. We intend to receive this damage like an enemy. And we're going to be creating an enemy in the next series of videos so we can test our fireball electro spark against them. So to do this portion of the video creating a damaged grip for our electro Spark, we're going to be working inside of our BP electro spark and that is in our blueprints, actors. There is our BP electrical Spark, open it up.

And you're gonna see some event nodes here by default, just left click drag and delete these out. And the thing I want to add an event for is if we detect something has overlap this collision here, and again, I'm just going to right click in our view, I'm on my viewport tab. I'm just going to Right clicking here with my collision component selected, tap the F key to frame up on it. I'm talking about this collision sphere, kind of calculating all of our electricity. So jumping back to our Event Graph, I'm going to right click on my collision component, we're going to add an event and we're going to add an on component begin overlap. So I want to do something when I detect that something has overlapped this and what do I want to do I want to apply some damage to what the other actor in other words, the other thing the other actor that is overlapping this collision volume, so I'm going to drag out of my other actor output pin here.

And I'm going to search for apply damage this function node or right over here. Now it's going to hook in the execution wire right away. I'm just going to hold down the Alt and left click this because I do want to put some nodes in between here and I'm going to create Some separation between these two and I'm going to bring in a reroute node by left clicking a couple of them on this note because I'm gonna sneak in a few other nodes between these guys. So I want to apply some damage to the other actor, but I want to know how much damage Should I apply Well, if I right click and get my player character and then if I drag off of my player character and cast to my BP player, I will hook in this execution wire to my test to be there.

And then I drag off of my as VP player here and I do a search for my electro spark attributes we want to get the electro spark attributes. Remember that was a struct variable that lived inside of our BP player. I can then drag off of this and say, Hey, break open this struct, because this struct contains some information that I want to get it, I'm going to click this little drop down here. Namely, I wanted to get at how much damage is electrical spark meant to do. And just jumping out of this blueprint temporarily on over to my BP player. And I go under magic black electro Spark, my electro spark attributes, there is this struct.

And I can see over in the Details panel that this is meant to do 100 damage. So that is what I'm doing over here in my BP electric Spark. I'm grabbing this attribute these electric spark attributes out of my player and saying, hey, how much damage is electric spark meant to do, then I'm going to plug this damage into my base damage right here. Now I don't want to plug this straight away into the applied damage. I'm going to drag off of this and say do once. So I want to apply this damage one time.

But then I'm going to drag off of the output of my applied damage bring in a delay node that I will set for 2.1 seconds and then take the complete from this and plug it into the reset of the do once node. So what am I essentially saying here? Well, what I'm saying is that when we cast out our electric Spark, which is going to cause this to appear and grow in size rapidly, if it overlaps another actor, in which case it's going to be an enemy for us, we're going to apply 100% Damage one time and then we're going to wait 2.1 seconds before we allow that to damage it again why 2.1 seconds. If I right click I will leave a node comment. This is the same time as our electro spark cool down are electro spark cooldown is 2.1 seconds so I'm essentially going to only allow 100 points of damage per time that this is cast.

Now when you cast it out again, you can cause another hundred points of damage so that's why I am doing that. Okay, I would like to play test this but we really have nothing to play tested against yet. We've got some enemies upcoming next that we can test out this end our fireball against. So let's just Compile and Save and move on to the next series. We'll see you there.

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.