Target Lock on Enemy UE5

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello and welcome back so let's start by the things that we need to import but first of all let's create a new folder here called the call so now let's search for the circle transparent let's import the circle mine is right over here just make sure the background is transparent so we're gonna right click on this and create a material so that's going to be our material double click on this you're gonna have to click on here a circle on the material domain you're going to choose different decor the blendboard is going to be translucent because it's transparent and the rgba is going to be opacity after that you can click on Save and that's all you got to do on the material so now our material is ready to use you can close out of this so if you drag and drop here you can have an ID of this scale so for this tutorial you're going to need a bot but we don't have a bot so we're going to create one I'm not going to like make a bot like an entirely new one because you know that's not the purpose of the tutorial but we can we can make a character here I think it's a character and here on the mesh we can choose the S key mannequin and as done that you can compile and close out of this and then you can drag and drop into the world and that's gonna be our bot let's suppose that's our bot okay we can name this spot this is a blueprint and there you go and we're gonna double click on the top on the pop on the bot all right I can't speak uh open the full blueprint editor go to the viewport and we're going to add the decall so let's just type here decal and of course we gotta adjust that a little bit here on the call material you're going to choose the circle met we're gonna adjust the size like so and like this like that when we hit play that's the preview of the decal on the ground how it's going to be that's perfect okay that's what we want and here we can uncheck this option here visible because we don't want to see when the when it's not targeted all right we don't want to see the decode when it's not targeted all right so now we can compile save and close out of this that's all you got to do on the bot now let's go to the third part so the next step is going to be on the third person character so what we have here is just a simple code what we have right now here is just a you know we have our character and we have the bot uh so when we press the right Mouse button we want to Target we want the the camera to move when we press the right Mouse button and for doing that we're going to get the right Mouse button so let's type here right Mouse button uh we're going to create a new variable called sorry okay so we're going to see we're going to want to know if the target is locked or not so we can name this target locked and exclamation part mark so that's going to be our blueprint let's compile here so we can get the the option drag and drop and set let's duplicate no no let's just so when we press release we want to get the target unlocked so when we press the button we're going to want to get the sphere Trace for objects of course the bot is the object so in this case here um on the draw debug type we're going to get for duration but you can also choose persistent the lines that appears in the game they disappear after some time so that's why I like the four duration one but you can choose whatever you want whatever is better for you and here on the object types we're going to click right click on this and let's promote it to a variable and here is asking for us to compile so let's just compile here let's go back so here on object types is asking you can add as many as object types as you want so in this case here our bot is upon so we're going to add Pawn let's get actor location the active location is ourselves the end is going to be get forward Vector of the follow camera so let's adjust this we're going to multiply this type multiply let's duplicate this Ctrl C Contrary we're going to connect this to here and this to here this to the end and here on B we're going to right click we're going to convert pin and we're going to choose the float here you can type 1000 all right so when we compile oh I forgot the radius you can set the radius should be 122. so as you can see that's our bot and when we press the right Mouse button you can see that there is the red line and the green line means that the target was hit so if I go here you can see that and keep doing this it's tracking the object that's why you got to choose in the object types you got to choose the pawn all right that's very good so far so let's get a new branch so when the target which is our bot is hit the return value is going to be true and if the target was found which is the bot we are going to want to set we're going to want to tell the variable that the target is locked we need this information so variables are for restoring information if you don't know and if it's not if we couldn't find the bot we just uncheck this option all right and let's print a string here saying that hey the target is locked Target file and out of hit we're going to break hit result so we can get this option here of the hit actor you have like a lot more options here what I want is the hit actor so the hit actor is going to be the bot and I want to promote this to a variable and I want to get is valid so we don't get any errors and here you can double click on this blue line and drag this to the input object organize it a little bit and connect to connect is valid to set very good so when we compile save and press play I'll press the right Mouse button it says that the target is locked when I'm far away and then I'm not near the Pod it doesn't it's not going to catch all right that's everything I gotta do here on the object types I guess so let's jump right into the to the event begin play so let's type here event begin play we want to get Vector of class we're going to select the but blueprint so just type here bot whatever you named it here it has to be the same name here on the return value we're gonna right click and promote your variable and here you can name it Bots or whatever you want all right that's all you got to do here on the event begin play now the last part is event tick I'm gonna link this website here so you can copy and paste the code so it don't waste too much time on this all you got to do is just come here and select everything ctrc ET Ctrl V so you only have to worry about this this part here just gotta connect it and the heat actor you got to make sure the hit actor has the same name as this uh here on the event graph we're going to want to check if the target is locked or not sorry get Target locked we're gonna hold B and press left Mouse click we're gonna connect it to the condition and that's why it's important to set the variable to True here we gotta know the information if the target is locked or not so if it is locked We're Gonna Wanna set we're going to want to go here and set control of the camera so this code that I posted uh on this website here is going to control the camera so when we press the right Mouse button this code is going to be executed and the camera is going to be dragged so as you can see here when you press right Mouse button and hold it as you can see the camera is being locked to the Target but it can still control my mouse it just if I move up it goes back down again automatically because if you want to disable your mouse when you are targeted into the enemy so what you got to do we gotta modify the mouse you're gonna modify this code so let's get a new branch so again we need to know if the target is locked or not so just drag and drop to the condition and move up and down okay this controls the left hand right and then this controls the up and down so we're going to get a branch for two of them and then we're gonna put this and then here if the target is not locked then we're going to we're going to get the normal models movement so if the truck is locked we're not going to be able to move our mods anymore because this target part this uh thing this function here is not going to be executed so so as you can see here when I move my models it doesn't happen anything now that's if you want the the decal now we're going to learn how to put the decode on it but first of all Let's uh disable it let's disable this charitable type so you don't get the trace line again uh here we can just drag this a little bit we're going to open this just hold it out and then click on here and true it's going to unpin the line so we're going to want to to get the bot so drag and drop here get bot and let's get the decal uh just scroll down and you're gonna see here and we're gonna set visibility of the decal and we're going to duplicate this country C contribute false we're going to plug that into here and shoot there if the target is locked it's true we want to set the visibility on if not then off when we play and then there you go so that's going to be the end of our tutorial I hope you enjoyed and I see you in the next one bye [Music] thank you [Music]
Info
Channel: LocoDev
Views: 8,544
Rating: undefined out of 5
Keywords:
Id: fgdH7C8Ys4s
Channel Id: undefined
Length: 13min 1sec (781 seconds)
Published: Fri Nov 04 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.