How to deal damage to AI Enemy in Unreal Engine 5

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
so previously we made the AI attackers today we're gonna make so we can actually attack them back let's go first thing to do so let's create a folder because we have to stay organized let's call it combat uh let's say the beautiful color to it as like bluish bird polish gonna have a new folder let's call it nodify and another one we're gonna call it animations because when we're gonna attack we will have animations and for the animation so actually like to actually attack it so we will have no device so we we can actually detect when we actually hit something going into our third person so locate your third person card so in here we're gonna go to the viewport we're gonna make this simple uh and we're gonna click on the merge node and we're gonna add a component called Static mesh or use static mesh and let's call this uh weapon and add the static mesh whatever weapon you want for me uh I added the sword uh this is completely free by the way [Music] so um I'm gonna go check sword out bam you can see that the sword so now we're gonna and there should be pattern sockets right uh and search for a hand so hand right here you can see now it's kind of like wiggling how you can actually just click on the mesh pause items okay I'm just gonna pause the animation and now you can adjust the sword so it's in uh out hands [Music] so you can see we have our weapon enough so you can make it smaller the sword also so if your compile and save it and now if you press play you will see you have a sword with the animations that actually pause so uh you should and pause them so when pause the animation compile save it now you can see we have our sword in our hand this is basically we just plugged household in our hand that's that's basically it so um we're gonna make it so we can actually attack uh to to actually do it there's a lot of ways to do it we're gonna do it with another Farm so I imported a salt slash so you can see you can see uh default sword slash animation so what we're gonna do we're gonna right click on the animation create anim montage and that's basically it so if you open that up you will see uh the animation and uh no device right here so we're gonna create a node for you right now so right click uh go to blueprint class there should be node if node default and you can see there's a lot a lot of states are we going to do anim notify state select that and we're gonna call it attack King I'm gonna call it attacking uh you can see it's kind of like empty and stuff uh kind of sad I'm gonna go to function override and you can see there's a lot of like save no device and stuff I'm gonna receive notified take so receive not if I take so from the mesh component we're gonna get all winner so we get on suit the person uh character connect the PIN we're gonna get weapon and just scroll down that should be get weapon so the weapon is uh this weapon that we selected uh some sword and then get a socket location we're gonna create the sockets later uh but we're gonna get the location of it so create two of them because we will need the end and the start location so uh from the character execute gets sphere uh trace for object so this one and you will see uh it's a launch race of course so the sphere Trace I call it launch racing from the first socket go to start and the second is the end one uh the radius for now let's do 50 later we're gonna adjust it World contest object that's the mesh component uh draw debug for duration then after the spirit Racers turn value will be a brand so we are gonna check it out hit will be just break the hit so you're gonna break it and we will receive all these pins we're gonna get to them later on adapt to ignore is this one basically yourself and the object type uh create now but make an array and the object type will be a pawn so basically what we're doing right now we are getting the weapon mesh then we are getting the sockets of it that we're gonna create later on then we add making a sphere so whenever it hits something it's going to deal damage right so we can actually kill the pawn so aka the AI what bro what are you talking about man let's create the sockets so let's do it we have to go to third person character select your weapon you will see the static mesh and just search it open that up and there should be details on socket management go to socket management click on the plus sign uh a name it start and another one name it end so now you have a first socket in the classroom so this at the end will be your basically the tip of the Sword and the stud will be where the blade is uh started so it will it should look roughly like this you can save that remember the name so uh start and end so now we can actually make the socket names as a start and uh end and now it does basically so you can actually test it out it's not gonna deal damage but we will see the tracing so go to your sword slash montage and right to where it starts where it's gonna swing right here write down the notify the first one right click go to add notify state go to attacking and extend it till he uh sweeps back I guess so to test it out we're gonna go to third person go to event graph and create I guess the left Mouse button yes uh play montage the first one play Montage select your Montage it's gonna be right here so it's nice uh the mesh is the skeleton mesh component compile and save it so if we play you can see it's going to generate a big ass sphere around us and it's it's quite big it's quite big so let's make the radius as 15. so let's cut it out a bit as you can see now this tracing L is a little better you can see there's there's some gaps as well so to conquer the gaps there's there's different ways but that's gonna be for another tutorial probably so uh make the tracing complex as well uh make the radius to like 25 maybe and now if you're suing it should make the gaps a little smaller because every time you hit um it's gonna go green so you can see it goes green would we have some bugs like for example when we move it's kind of like the legs are kind of way off so we're gonna fix it by going into outer person so going to character then mannequin and then animations you will see uh the animation pack so the logic is in the ABB menu so open that up and you will see all the local motion all the scripting all that kind of stuff so right here in the anim graph run there's all these something set up or what are we going to do is I'm kind of confused what the [ __ ] is this [ __ ] layered blend per bone so we're gonna take this one you can see it's all the um saved so you can do local motion use catch pose if you don't have it but you have the state machine you can just do save catch pose and then just use it so you're gonna do this as a bass pose and copy paste and we will need a default sword so we're gonna copy the default slot or you can just type default slot connect that into the local motion connect that to the blend post zero and change the default slot to uh upper body compile and save it it's not going to work right now because we have to go back to your sword slash change the default group to short name right here upper body do layered blend per month so this will be the bass poser here at the positive will be the layered upon permanent and to actually layer them or make the upper body work uh you have to just click on the layer layer blender body so basically what we are going to do here is uh we're gonna blend only the upper body so the legs will have the default animation but the body the upper body will have a different animation so they they will be like different so click on this click on the plus sign open that up and the bone bone name will be spine zero one I think hopefully you can go check it out you can see spines 0.01 and the skeleton you can go back spawn zero one copy that and paste it in the layer plant Port bonus well it's basically uh similar so now if we actually play and swing you can see your upper body will actually swing but I kind of don't like it because it's kind of weird so so you can go to open arms right here you can copy the name I'll put on [Music] um paste that in here or put on L click again click another plus another index and operate so these two arms will only work so now if we play you can see now it's a little better um you can you can test it out yourselves how it feels uh I like this one I think it's better like like here you can like damn you cannot damage it so you're gonna make it so you can damage so going back to the spaghetti that we created so we're gonna create a new overhead of receive node if I begin from here we're gonna do uh clear we're gonna create a variable called uh damage actor this will be a variable actor so search for just it should be just actor and object reference and the pin is an array so take that and do a um do clear I'm so sorry today is not my day okay just connect that connect that created new function just create a new function let's call it can damage uh actor question number so it's a question mark so we're gonna make it pure now we're gonna do an input of enacter or no input of actor so actor we're gonna do the damage actor and we're gonna do contain item plug that plug this pin into the actor one and we will need a return value I will explain what we are actually doing uh just a second if it doesn't contain notebook that in so basically on the now if I begin we're gonna clear all the damage actors so everyone that we have damaged it's gonna it's just gonna create clear the records of damaged players okay we then we're gonna check can Dam injector so does the container aka the damage actor container because it's an array does it contain an actor I guess does it contain an actor if it does if it does if it does it's not gonna damage if it does not it's gonna damage it so so then we can go back to even take we can take the can damage we can see plug the actor into the heat actor of course it's a branch because it's a Boolean because [ __ ] booleans and do apply Point damage plug that in and the Damage will be like let's do like 20. but actually 25 kind of had nice but here from Direction that's the Imp I have no idea heat information click the information then caused the heat actor normal damage I hit hit from Direction probably the impact impact or point I know I just plug that into location I have no idea damage actor detector compile and save it this is uh kind of nice spaghetti not going so long um kind of love it and after that after the point damage we actually have to get the damage actor add a unique plug down and this pin will be the heat actor so basically if you're adding uh we are adding to the array that we actually hit so hopefully it's understandable because my English is not [ __ ] red okay now going into our AI so just uh let's just click on them let's go edit oh what the [ __ ] is this bull cap damage so right here even Point damage and let's just print string uh let's just pinch thing like here damage so you can actually see that you're dealing damage so if you go up to the AI sub [ __ ] oh you can see we are actually dealing damage come here come here now what we're gonna do in the nmbp we're gonna create a health is going to be a float I'm gonna set the health over here we're gonna do minus so health minus damage plug that in here and then we're gonna have a branch if the health is less than zero no if the health is less than or equal to so you know I'm so sorry if it's true uh we're gonna destroy the actor so destroy vector if it's false it's gonna just print string hello it's gonna print string the health so if we play right now and if we attack one of them we killed them oh the health is less than so add the helpers 100 by the one compile and save it so now if we play we can actually fight back holy [ __ ] come here boy come here come here oh gosh I I spammed it I spammed it you can see I just killed him you can see we can actually kill him and that that's that's basically it so hopefully I hopefully hopefully you'll learn something from it if you did uh press that like you know subscribe do whatever to help the channel grow because I want to upload more but I don't have the money to do it
Info
Channel: Lunar9
Views: 1,719
Rating: undefined out of 5
Keywords: unreal engine, unreal engine 4, unreal engine 5, games, videojuegos, ue5, RPG game, tutorial, quixel, unreal engine RPG game ai, RPG game unreal engine 5, ue5 RPG ai enemy, ue5 beginner tutorial, ue5 how to make an rpg game, unreal engine 5 ai combo attack tutorial, unreal engine 5 easy RPG behavior trees, unreal engine 5 assassins creed advanced ai, ue5 ai combo system, unreal engine 5 soldier tutorial, ue5 RPG series, unreal engine 5 games, unreal engine 5.1
Id: vsSlfmJCT7Q
Channel Id: undefined
Length: 18min 25sec (1105 seconds)
Published: Wed May 03 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.