How to do AOE damage and healing | Unreal Engine 5 Tutorial | ue5

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] welcome everyone to another Unreal Engine 5 tutorial in this tutorial we'll be creating aoes these are spells that damage or heal an enemy or player in an area so sort of like this fire that if I'm standing in it I take damage also this bomb that I can spawn and damage both myself and the enemy uh also a heel in place like this so if I'm outside I'm not healing inside I'm healing and finally a lightning strike that does an indicator and the enemy can also do the same to us so wherever the player is the enemy will be spawning lightning and if it hits me I take damage and I can kill the enemy the same way oh now we're both dead let's get started all right so I'm going to start here with a third person template this time just so that we have a character to move around with I'm going to also enable the starter content and call its AOE tutorial now I've already created this so I'm not going to do that again of course but then here's my third person templates I'm also using the FX variety pack which is just this free acid pack on the unreal Marketplace I'm going to leave a link for it down in the description and I'm using some animations and decals that I created myself I'm also going to give them for free for my patreons so first thing we need to do is create an AOE folder which I've already created here but it's empty and we want to create our first actor which is going to be our AOE base now this Base Class is going to contain everything that's common for all of the different AOE types we're going to create so let's think what is the most common thing for an AOE or the AOE in its simplest form so let me delete these two now in a way in a simplest form is just a sphere Collision so let's call here sphere overlap actors now this function creates a sphere in a specific radius and gives you any actors that overlap with it and that's how we're going to set up our basic AOE now this is going to have a location let's just say this is wherever this actor is in the world it's going to have a radius let's promote that to a variable and just call it radius um and let's compile so that we can also default this to I don't know let's say 200 is going to be the default for this and the object types pull off of this and say make array now for me I'm only spawning I'm only colliding with pawns if in your game you also want to collide with the like different objects or things like that just to make sure to add them here but for my case spawn a pawn will work fine and finally actors to ignore um usually when you create an AOE you want maybe to ignore yourself so if I'm doing an attack maybe I don't want this attack to damage me so I can say get instigator here and this is what we'll ignore an instigator is the actor that spawned this other actor class um most often you also want this to be um an option so sometimes you want like a bomb to maybe damage yourself or for your or your friends and maybe you don't so let's add a variable here and call it ignore instigator which will be a Boolean defaulting to false and if ignore instigator is true then we'll add this otherwise we won't so to do that in a simple way we can pull off of this one and say select put our ignore instigator as the option so if ignore instigator is true then we will add this instigator uh in our array otherwise we will not ignore anything and then anything that comes out of here or anything that overlaps with this sphere will come out of here now we also might want to draw a debug sphere so that we can actually see it so this does a regular sphere Collision but we can also call draw debug fear to actually show us something in the world oh let me move these a bit over here all right so also the center will be the actor location the radius will be our radius as well and I don't know let's make it something purple yeah this looks good um and the duration let's draw it for I don't know one second or two seconds thickness also give it one and pull this here but just so that it's also configurable let's only draw this if um we have draw debug sphere is true so I'm going to create a variable here called Draw debug sphere [Music] and only if draw debug sphere is true then we will draw this debug sphere um all right so let's take a quick look at our variables radius we don't want this to be editable by the person spawning the AOE but ignore instigator and draw debug sphere yes so make sure to click this I icon and also click on expose spawn up here on the right so it's instance edible and exposed on spawn but radius is not we'll leave it as is remove these a bit here all right so let's see what this looks like um in the world so if I go here throw this and I press play nothing happens because draw debug sphere is false so if I say draw debug sphere to true now we play you see yeah a sphere is drawn for two seconds and then disappears now if I'm in the sphere something should happen and that's what we're going to do here um now for we're going to pull out of the out actors and do a for each Loop that means for each actor that is overlapping the sphere or each actor in The AOE area we want to do something now this is something we're not going to Define in the base class in the base class we're just going to call an event so down here in the event dispatchers at an event call it on AOE overlap actor and this event will just be called and it takes an input on here on the right is the actor that we just overlapped with so this is going to be of type actor object reference now if you pull it here and say call now you can pass in the array element as your actor now what we're doing here is we're just dispatching an event or we're saying that this event happened and the person that's spawning the AOE will handle what happens on this event um in object oriented programming this is called separation of concerns or in general programming this is to separate the what the base AOE class knows about what's happening in the world outside it and what the actors spawning it actually knows to make our project more manageable and maintainable now you'll see in a bit how this is happening um but we can also hear just for you to see we can print the name of the actor that we're overlapping with all right so if I go here and I spawn it's here you can see that I'm printing on the top right BP third person character because that's the actor I'm currently overlapping with great um so now all of this happens on begin play um but I don't want it to always happen on begin play so I'm going to create another event here call it um uh spawn AOE sphere and I'm gonna move all of these things to my event here now the reason I'm doing this is maybe because I want this to be called multiple times on beginplay so let's say for example I do a set timer by events and every I don't know three seconds set it to looping we're going to call this spawn AOE sphere now if I play well that's a bit small and let me maximize that all right so now if I play you'll see that's every three seconds it spawns the sphere now and if I'm inside it it's going to print on the top left that it overlapped with me great so this is an AOE in its simplest form but we want of course things to happen but this for now is our base AOE actor I'm going to remove this and I'm just going to um call spawn AOE sphere here all right we're going to come back to this and make a few edits but for now I want to discuss what types of aoes we're going to have so we're going to have something like a an explosion or a bomb and an explosion is just a single event AOE so it happens once and then disappears as opposed to an AOE over time for example fire on the floor if you're standing in the fire you want to keep getting hit every second or every certain amount of time so we're going to create two separate classes for these two types so back here in our AOE folder I'm going to right click and create a child blueprint and I'm going to call this VP AOE blast so and I'm going to also call it base because it's also a base class now this blast base is going to be the base class for all of our blast effects like explosions and things like that that I mentioned now let's open it up and see what differences it's going to have um so now in our Base Class we have the spawn AOE sphere and it just calls A dispatch is an event when something happens but maybe for our blast effects for our blast bass we also want a particle effect to be played and we want it to be played only when the spawn AOE sphere event is called so to do that back here in our AOE blast we can actually override or extend an event from our parent class so if you search for events spawn AOE sphere then this you're basically overriding the event here in our base class but we don't want to override it we want to extend its functionality so you can right click on it and say add call to parent function this basically says do whatever you're currently doing in the parent which is all of this stuff and then add something to it and that's something for us is going to be spawning a particle so I'm going to say spawn emitter attached now I'm using the Legacy Cascade system so I'm using spawn emitter if you're using Niagara I think it's a spawn system attached and then you can add Niagara effects I don't have any Niagara effects so I'm using this one um now the emitter let's promote this to a variable and call it blast effect and we also want to destroy this actor once the effect is over so if you pull off here you can say well it's happening with my mouse okay yeah that is weird what's going on there we go okay so if I go here and say Spa um assign on system finished this is an event that will be dispatched when this effect has finished so let's call it on or I just call it system finished events and here what we want to do is just destroy the actor um now for good practice Also let's only do this if blast effect is valid so if you go here right click say convert to validated get then we can only check we only do this if is valid is true otherwise we don't do any of this um yeah maybe if is valid is false just uh wait one second and then destroy actor maybe that's also good practice um all right so this is our blast effect now let's create a oh actually one more thing we want to add maybe we want to add a sound so let's also create a blast sound I'm gonna go here and say play sound at location and the location is our get actor well no this one get actor location and we're going to promote this to a variable as well call it blast sounds now we also want to convert this to a validated get and only do it if it is valid great um now I want to clean this up a bit so I'm going to take all of this and put it in a event I'm going to call it custom events call it spawn blasts effects great move it a bit here and I'm going to take this and create another event call it play blast sounds all right and then here in our event spawn we're just going to call play spawn blast effect and play blast sounds great now let's create an actual um explosion effect that's going to be a child of this blast base so in here in our content browser right click off of the blast base and create child blueprint class call it BP AOE explosion now open this up you'll see here in your variables the blast sound and blast effects and by the way if you don't see them click on this gear icon and say show inherited variables so you see the variables coming from your parents now blast effect we're going to set it to the explosion effect that comes with the starter pack and blast sound we're also going to set it to the explosion queue sounds like this also comes with the starter pack Now by just doing this um let's compile and save and throw this uh let's delete this old one and let's throw our explosion in the world here and let's see what happens well that was too quick to see actually so let me add a delay here in the Base Class Let's uh only do this after one second um I Heard the sounds but oh I have an error here uh it says access none trying to [Music] um oh I forgot to say where to attach it so you need to attach this to your root components and the reason I'm doing spawn emitter attached instead of Spawn emitter at location is because when we destroy actor it also destroys anything attached to it so that's easier for cleanup so that the effect doesn't remain in the world even after the parents destroyed all right now let's look at it yeah you saw it but it still was compiling shaders so let's look at it again there we go now we have an explosion somewhere in the world and we have two of them for some reason now let's move it a bit up so that it's clear great there's our explosion and if I'm standing in it oh it was too far and if I am standing in it again nothing happens why should print uh let's actually go here and say draw debug sphere so we see how big the sphere is oh yeah there it is and there's the print uh it's weird don't know why it didn't happen the first time but yeah it's working as expected now but as you can see this the debug sphere is a bit too big for this explosion so either you make the explosion bigger or the sphere smaller um in my case I'm going to go here to the explosion and edit the radius let's say make it 100 instead that's that's a lot better now what we can also do is let me delete that and spawn this in our third person blueprint so if I go here to our third person character I'll just find somewhere empty and say um keyboard I know X when I press the X key I want to spawn an actor from class this is going to be our explosion AOE um where do I want to spawn it I'll just spawn it where the current player is so get actor location right click split this transform and plug in your location I'm not going to say ignore instigator because we wanted to hit ourselves in this case um but I also want to push myself back or do like a um an effect when something happens so I'm going to say assign on AOE actor begin overlap and this is the event that we dispatched in our Base Class when an actor overlaps with this AOE effect so we're just going to call this something like a push back player and what I want to do here is pull off of this actor um and say oh I'm just going to go here and say launch character this is a function that I'm going to use to launch myself in the air and now I can't pull the actor here this is the actor that's overlapping with the sphere uh but I can say if actor equals self that means I'm overlapping with self put a branch here if actor is equal self then just do this on itself another way to do it is you can cast this actor to a character and then call launch character on any character but now we only want to do it on ourselves you can also click these two um now let's see what it looks like if I press X an explosion happens but the character isn't being launched in the air uh let's check why so first I'm going to remove this delay because it's quite annoying and now if I press X yeah the explosion happens right away but no prints and nothing else um let's draw the debug sphere to make sure that we're in the sphere yep we're in the sphere quite well oh I actually know it's quite a bad bug when I draw debug's fear only in this case does the rest happen that's because off of false we should also go to the sphere so draw the ebook sphere shouldn't impact the rest of the functionality so this is a very important connection to make all right um so the print is happening but this isn't being called and I know the reason it so right now we're calling um on begin play We're spawning this right away right but we're not giving time for the character so or this uh blueprint to actually bind to the event because this this bind takes some time after this is spawned which means that in the base class this is being called first before any binding is happening so to fix that let me remove this here so on begin play we're not going to call this spawn AOE sphere we're going to create a new event call it trigger and in this trigger event we spawn AOE sphere now the reason I'm doing this is because we want to manually trigger These Blueprints so for example here right after I bind then I can pull off of our explosion and I can call trigger now I'm making sure that I'm only triggering after The Binding is done which is very important now let's see what this looks like there we go explosion and I'm being pushed back lovely um now after adding this uh this trigger event we also might want to modify here in our base to instead of overriding the spawn AOE sphere it's better to override the trigger events because it's more General so add call to parent and then this is what we're going to use instead all right um this shouldn't change anything it should still work as is great all right and that's our blasts AOE um now I also mentioned that we have another type of AOE which is the sort of AOE over time um now I'm going to go here and off of our base I'm going to create a new child call it BP AOE over time Bass now as I mentioned this can be something like you know you're standing in fire or there's an AOE heel that keeps healing you as you keep standing in it so this is going to behave slightly differently um it's going to have two additional variables one is going to be our interval or spawn interval this is going to be of type float this is how many times the sphere should spawn so every time the sphere spawns either you take damage or you do a heal or basically the event is dispatched so how often this should happen um let's default this to one second um make this instance editable and expose on spawn as well you might want to edit this um and another one is duration how long should this remain active for when should it disappear or be destroyed again instance editable expose on spawn and less default it to five seconds um great so right now if we look at our Base Class we have this trigger function that calls spawn aoesphere only once but we want to override the trigger to call it multiple times so we're going to go back here to our [Music] AOE over time and we're going to say event trigger and we're also going to right click and say add call to parents um and just so you remember in the Base Class the parents of the trigger just spawns the AOE sphere so basically what we're doing here is say on trigger We call we spawn the AOE sphere but we also want to do something else we want to keep spawning it every interval here so we're going to pull off here and say set timer by events and the time is going to be our spawn interval so every one second as we defined here and set it to looping we want to call an event the event we want to call here pull off and say create events and just select your spawn AOE sphere so here you have access of force to all the base events so spawn AOE sphere is one of those um now we also want to do something else we want to check for the duration after a specific duration we want to destroy this actor I'm going to move this here let's actually create a sequence to tidy things up this is the first thing in the sequence and the second thing is also set timer by events and this time the timer is our duration not looping because we only want this to happen once and this time the event is create event is destroy actor and this event comes with the every actor class of course all right so recap what's happening here every spawn interval we're going to keep calling spawn AOE sphere until duration is up then we destroy the actor um now let's see what this looks like um I'm gonna create a child of this right click create child blueprint class call it BP AOE fire now this is going to be fire on the floor and as you're standing in the fire you keep taking damage um actually one thing we also want to add here in our um fire is spawning the effect of the fire now this might not be the case for all AOE over times so I'm not going to add it in the AOE over time class I'm just going to add it specifically in the fire class so I'm going to go here say event trigger um no actually we don't want this on trigger because trigger happens um no no that's right trigger only happens once so we do want this on trigger add call to parents and we want to spawn um emitter attached attach it to our root and the emitter here is fire all right so if I go here in our world and place this fire you won't notice anything and I'm going to explain why um because we're not triggering it so if you recall if in our third person we had to manually call trigger here um now we could of course open the blueprint of the level so if I go here and say open level blueprint I can take this bpaoe fire and just say um trigger and call this on begin play now this will trigger the fire as you can see here um but if you don't want to do this we can also add let me close this we can also add in our base a variable here and just call it trigger on begin play it's going to be a Boolean and if this Boolean is true trigger on beginplay and then you can call trigger I would recommend doing a delay like a very small delay here just to make sure that if something is binding uh or anything is happening before trigger then it has time so let's keep it at 0.2 it should be fine now I can go here oh I don't have access to this trigger on um on beginplay because we didn't make it instance editable and expose on spawn now if I go here I could just say trigger on beginplay great now we have our fire and if I'm standing in it you can see on the top left that it keeps um uh Printing and after five seconds it disappeared now you can look at this again print print um one thing we didn't do though is draw debug sphere to see how big it actually is so the sphere is a lot bigger than the fire so I'm gonna go here and play around with the radius a bit say I don't know 100 um yeah maybe 80. yeah 80 is better all right and that's basically your AOE over time you can also play around with these durations so I can make it spawn interval 0.1 that means I want to take damage every 0.1 seconds and keep it spawning for uh 10 seconds so now the printing is happening every 0.1 seconds and it's going to keep spawning uh keep spawn for 10 seconds nice now let's create another uh AOE and this time it's going to be a um an interesting one it's going to be a lightning effect um and it's going to be different than the others because it's going to have a delay you know how in games sometimes before an AOE effect happens you get an indicator that it's going to happen in a specific area and then after a delay it happens um that's why I created this decal here so for example um you see this indicator that oh something's going to happen in this area then after one or two seconds lightning strikes so that's you know to run away in time and this is what we're going to build now so back here in our AOE folder this is a blast AOE it's nothing over time because obviously it just happens once and that's it so are going to create a child off of our blast call it AOE lightning strike great now go to our event graph here and off of begin play so as soon as this actor respond we want to spawn a decal at location and the decal material here is going to be my lightning strike that I created and the decal size is 25 256 256 this is the size of the decal as I know and the location is wherever you spawn this actor so after that we're going to say wait so I'm going to do a delay of certain duration this can be configurable so right click promote the variable call it delay before strike make it instance editable and expose on spawn compile and default it to like I don't know one second and then after this uh one second then we call trigger again this is another reason why we don't call trigger on beginplay because in this case we want to trigger uh the explosion or the effect after something happens then after trigger we want to destroy our decal so pull off our decal check if it's valid first it's always good to check if something's valid before accessing it after some time and if it is valid say destroy components great now all this happens on beginplay which means that as soon as you spawn this AOE it's going to wait this duration and then trigger um let's see what this looks like if I put it here in the world oh one more one important thing before we continue we need to add the blast effects for our once it triggers and here this is going to be P underscore KY lightning three this came in with the FX variety pack that I am using and the blast sound I know let's use explosion again it's fine uh great let's see what this looks like in our world place our lightning decals spawned and lightning hit after a second and let's add the delay a bit make it uh three seconds so decal lightning nice and if I'm standing in it boom triggers a print on the top left you can look on the top left of the screen you're going to see printing that this actor is damaged just like the prints that happens here um very nice now I want to add one thing to show you what happens when you spawn this um from our character class so just like we're doing here when we press X I want to change this to be our lightning AOE and then you see all of our additional options here so delay before strike two seconds um yeah leave everything as is oh we didn't also check our radius very important to check our radius so draw debug sphere and see what the radius looks like it's wanted slightly bigger um let me make this uh uh but where's our radius yeah so it's 200 that's C250 what that looks like yeah that was about the size of the decal right so my decal was 256 this is 250. yeah that's um that's good um all right so back here to our uh third person character um now we're spawning this AOE lightning wherever the character is um yeah you can keep the pushback that's fine we don't need the trigger because this is triggered automatically after this delay um but let's see what happens here when I press X let's delete these from the scene to not confuse us um yeah delete that okay now if I press X decal response but you'll see that it's not spawned under my feet spawned somewhere in the center of the character and that's because uh I have an error here oh this is fine let's uh just a fire that I deleted um it's because I'm spawning it to where the actor is and this gets the root of the actor or the spine Maybe um for the lightning strike we always wanted to spawn on the feet of a Target so to do that we're going to go back to our lightning strike here and add a variable call it um attack targets and this is going to be of type actor and object reference instance editable expose on spawn now here in my third person I'm going to well if I refresh this node refresh node I didn't compile now oh attack targets here so now I can put self as the attack Target now what this does or what we wanted to do is that if there is a target spawn the the AOE below the target's feet so let's create a custom event to do that custom event we're going to call it move to floor and what we want to do is see where the floor is from our targets uh we're gonna do a line Trace to do this so we're going to say Trace line Trace by Channel our start location is going to be our attack targets start location uh we can get actor location oh and also good to convert this to a validated get so that only if there's a valid Target will we do these things so our start location is wherever the actor is and our end location is going to be the current actor's location multiplied by 1 in The X One into Y and negative 1000 in the Z so that means whatever the current X is whatever the current Y is and negative 1000 in the Z and that's going to be our end so it's going to draw a line straight down from the target to the floor um actors to ignore you also might want to ignore the current attack Target so that it doesn't accidentally overlap with the Target that we're trying to find the feet location of um and now Branch here if there is a hit well if there is a hit then this value will be true that means that we hit a floor so we're going to break the hit results they break hit results and the location of the hits is going to be our new actor location so let's set actor location so now we're changing the location of our AOE lightning strike actor to be our new location and of course if there's no hit we won't do anything now before spawning the decal I want to call this move to floor function all right compile and save and let's test this out so I'm here I press X great now the decal spawns below my feet and if I'm in here boom I get hit and I'm knocked back nice just as expected um I need to compile this so that this error goes away all right um now one thing we can also do to make this look a bit nice is that maybe after getting hit here instead of launching the character let's say here we can just play um an animation so play Montage well if I can spell it play and a montage now I created just a basic hit or knockback and a hit back animation for this um so that you can easily visualize what happens yeah so you see here wait two seconds then he plays the hit animation um great now we're going to be creating one more um AOE before we move on to integrating it with our damage system to see how we can create attacks out of this so the next AOE we'll be creating is a heel AOE and the heel AOE is of course and over time so right click over the overtime base create a child and we're going to call this AOE heel now we're not going to do much here um we only want to extend our trigger so add call to parent function and we're going to spawn an emitter attached as well attach it to our root and the emitter here will be this heel Aura again this was from the FX variety pack um and if I say this Triggers on beginplay by default I put this here in the world compiling shaders it's going to appear in a bit Yeah and this is what the effect looks like so what we're going to do is if that if we're standing in it we want to heal but we're not going to be doing this now but as you can see on the top left it's printing so the event is dispatching correctly now we want to integrate all of this with our damage system tutorial from the first time to see how it looks like in game when we have an enemy and a player and they're both trying to do AOE attacks and heals and so on so let's get started now to migrate all of the aoes and all of the code that we added here to a different projects you can right click on a specific folder or assets or yeah like all of these three or something and right click and migrate now what migrate will do is it will find all of the things needed for these functions these folders to work or all of their defend dependencies and it will move them to a different folder so I'm going to migrate everything other than the starter content and the characters because I already have these in the other projects and then if you select OK it will ask you to select the content folder so I'm going to go to my damage system tutorial and select this content folder I've already done this before so I'm not going to do it again uh but now I'm just going to open to do unreal projects I'm going to open the damage system tutorial project now that we have this open and let me show you a quick recap so we had a player and an enemy uh the enemy was throwing projectiles at the player and the player could do the same thing now the player could also heal like this and I can kill the enemy and then I can heal again so what we're going to do is replace these project tiles with some with some AOE effects that we created now so let me first open up my um player so this is going to be BP player and let's take a look at what we have here we had one we left a mouse button then we spawned this this project tile I'm going to keep everything as is and just add a new keyboard event here so let's say when we press I don't know F on the keyboard then we want to spawn an AOE now if you look in the content folder I migrated everything so I should have the AOE folder here with the bass the fire the lightning strike and everything so here I'm gonna spawn my uh AOE sorry spawn actor from class and the class will be my lightning strike yes plug it in here and um well no sorry not promote the variable split and the location is going to be my current actor location I remember that this location is just a fallback because it takes a Target and the target here is going to be get actor of class and it's going to be our enemy so right now I only have one enemy so this is fine but in your game you probably want to have a targeting system that finds the right enemy but for me I just Target the one enemy that I have and after one second it strikes them and also I'm going to ignore instigator and instigator here is self so that's I don't damage myself with the lightning strike um now if I do this it's going to okay let me let me show you so if I do this and press f it's spawning lightning on the enemy but it's not damaging the enemy that is because we didn't plug in what happens uh on the AOE overlap event so let's pull off from here and say assign on AOE overlap actor let's call it well I already have damaged enemy event um now let's just call it damage enemy AOE and then here we're going to pull off this actor and call our take damage function now if you don't remember take damage this you can go back to the damage tutorial and see what this does but basically it just calls damage uh with a specific amount let's say amount of 20 the amount type let's do something like explosion these don't really matter now now the enemy should be taking damage nice and the enemy should die and they're dead great now I should not take damage in this because ignore instigator is true so this is working as expected um now what happens if we want the enemy to also do the same thing now we can of course copy and paste this to the enemy blueprint but I want to make it in a bit of a smarter way I want to move all of this functionality to an attack component so we're gonna go here to our content folder let's create a new folder and call it attacks and inside attacks we're going to create a blueprint class of type Vector component so it's similar to our damage system which is also an actor component we're going to have a bpc which stands for blueprint components called attacks now this is going to contain just a list of a bunch of attacks that any pawn or any actor can do so I'm going to take my lightning strike as the first one lightning strike and everything we did here in the player let's just copy this and place it here um all right now this oh let's delete the instigator we need to change this a bit but now the target maybe we want this to be a variable call it attack Target and the delay before strike let's also make this a variable and also the damage let's also make this a variable in our lightning strike function so that means you can play around with all these values when you call this attack now we want to ignore instigator but right now we don't know who the instigator is in um actor component so we can call get owner whoa already get owner um now owner here is of type actor but not of type Pawn so what we want to do is cast this to a pawn you can right click and say convert to purecast now if it succeeds you'll have a pawn if it doesn't you won't so I can select off of this and say only on success well only on true we'll use the pawn otherwise there is no instigator or the instigator in this case isn't a pawn so you don't need to ignore it um now this lightning strike function I can now go to my player here and just call well first I need to add this component so I can go here and say add our attacks bpc then I can pull off of a tax bpc and call lightning strike plug in my enemy as my attack Target one second delay strike and a damage amount of 20. let me rename amount here to um to damage amount so that it's clear what amount we're talking about now let me go to my enemy and do the same thing so the enemy if you recall had a on begin play every two seconds it would call attack now attack here is just a function that checks if they're dead if the player is not dead and it shoots a random projectile I cleaned this up a bit it was all in one node I just created events out of it but this is what we want to override instead of shooting random projectile let's say wanted to do an AOE effect so I can also add my attacks bpc to the enemy and I can call lightning strike instead of shoot random projectile and in this case the targets the or the attack Target will be our get player character I only have one player so index 0 will by default get this player delay before strike is one and damage amount is 20. um all right let's see what this looks like nice so now the enemy is trying to damage me with an AOE I can stand here take damage I can heal and I can press F and damage the enemy back with an AOE all right now we're both trying to kill each other with aoes and of course our own aoes don't affect ourselves great um now let's add one more thing in our attacks here let's add a heel um event or heal attack that's it's not really an attack but it's a spell or something so let's call this heel Target and what it will do is it will it will spawn actor from class and it will spawn this AOE heel that we created um now also what I want to do here is give make this take a Target so who are we trying to heal so in our inputs it's going to take a heel Target of type actor object reference and it's going to spawn it below the feet of this target as well so if you recall what we did for getting the location of the feet in the lightning strike this line Trace we want to do the same thing so in our attacks here before we spawn it let's move this a bit check if our and this is not then heal Target oh I deleted everything I only meant to delete this so check if this is valid and if it's valid we're going to do this Trace from the targets location I already had actor location called here trying I can delete that one and we want to ignore this actor so basically everything we did for the lightning we just want to do the same here and if there is a hit then we want to spawn this AOE at the hit location let's say it stays for 10 seconds and heals us every 0.5 seconds that's fine um now we need to assign on overlap what happens so heal Target say on heal Target now we need to check if this actor that's overlapping is equal to our targets yep and if this is true then call heal and we're going to use the heel from our damageable blueprint to make sure it's this one with the message next to it um now the amount let's say I don't know heal for 10. and if I go back to my player let's say I'm going to create another keyboard event so keyboard I know H when I press h oh we actually had it here yeah so when I press h i just healed now instead of heal I'm going to just spawn this uh heal Target from our bpc attacks and the target will be myself now the reason I have Target is that so the enemy doesn't heal in my healing spell and vice versa so let's see what this looks like now I can take damage let me kill the enemy and if I press h well I'm pressing H nothing's happening why so I'm passing a Target I'm calling heel if heel Target is valid do a line Trace if the line Trace hits then spawn um oh we didn't trigger so we can either say trigger on begin play or call the trigger manually here after we bind yeah now it should work again take damage press h uh nice and I'm healing if I'm outside I'm not healing if I'm inside I'm healing perfect works as expected as always thank you for watching and if you enjoyed this tutorial please consider giving a like And subscribe the idea actually for this AOE tutorial came from a comment on one of my previous videos so if you have an idea or you want me to do a specific tutorial please leave it in the comments below until next time [Music]
Info
Channel: Ali Elzoheiry
Views: 11,129
Rating: undefined out of 5
Keywords: unreal engine, ue5, game dev, AOE, damage, healing, blueprints
Id: ConO4G0j9wI
Channel Id: undefined
Length: 58min 20sec (3500 seconds)
Published: Sun May 21 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.