Electro Spark - Damage Script

Greg Wondra
A free video tutorial from Greg Wondra
Video Game Design Instructor
4.6 instructor rating • 5 courses • 13,720 students

Lecture description

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. 

Learn more from the full course

Unreal Engine: Character Skill System

Master the tools used to build "Fortnite" as we craft our very own character skill system using Unreal Engine 4!

25:45:13 of on-demand video • Updated November 2020

  • How to download, install, and setup a project in Unreal Engine 4
  • How to use the Side Scroller Project Template in Unreal Engine 4 to create a "Metroidvania" style game!
  • How to implement a Paragon Character (from Unreal Engine 4's stock of FREE assets) as a Playable Character
  • How to add acquirable Movement, White Magic, and Black Magic Skills to a Player Character
  • How to add Health and Mana Systems to a project
  • How to create supporting HUD and Interactive Menus using Unreal Engine 4's Widget Blueprints
  • How to Script Interactive Gameplay elements utilizing Unreal Engine 4's Blueprint Scripting tools
  • How to hook up Player Character Animations
English [Auto] Welcome back everyone. One more video here in our electoral sparks 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 gonna be creating an enemy in the next series of videos so we can test our fireball in electro spark against them. So to do this portion of the video creating a damaged script for our electro spark we're going to be working inside of our B P electro spark and that is in our blueprints. Actors there is our BP electro spark. Open it up and you're going to 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 gonna right click in our view I'm on my viewport Tab I'm just going to right click in here with my collision component selected tap the f key to frame up on it. I'm talking about this collision sphere kind of capsule dating 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 overlap this and what 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 right over here. Now it's going to hook in the execution wire right away. I'm just going to hold down the ult 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 cast to be people there and then I drag off of my as BP 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 going to click the sort of dropdown here namely I wanted to get at how much damage is electro 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 one hundred damage. So that is what I'm doing over here my BP electro spark. I'm grabbing this attribute these electric spark attributes out of my player and saying hey how much damage is electro spark meant to do. And then I'm gonna 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 gonna 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 two point one 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 two point one seconds before we allow that to damage it again. Why. Two point one seconds. If I right click I will leave a note comment. This is the same time as our you electro spark cool down our electro spark cooldown is two point one second so I'm essentially going to only allow one hundred points of damage per time that this is cast. Then when you cast it out again you can cause another hundred points of damage so that's why I am doing that. OK 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 and our fireball again. So let's just compile and save and move on to the next series. We'll see there.