How to Make a Spike Trap in Unreal Engine 5

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
what's up guys welcome to new Unreal Engine 5 tutorial and today I'm going to show you on how to make a simple Spike trap so we will go ahead and play an animation when we go over it and then also it will apply damage and activate a rack though so it looks like we just got killed it's gonna be a very easy view to follow so let's get started alright so the first thing that we need is to go ahead and of course get a spike trap animation so I have gone ahead and left this cool Sketchbook and free asset in description so you can just go ahead and download it and unzip it so once you have it unzipped you can just get the animation itself and it's dragged into the content browser and I will have a few you know different options to import so we're going to go ahead and click reset default so we have all the parameters as they are and then I'm gonna go into animation okay in the category animation and make sure that import animations is on very very important and then we can say import all or use import and there we go we have some warnings of some bones we always get that don't worry about that and now we have all the different components so let me just go ahead and create a folder so everything is a bit more you know uh organized so it's going to be your strap and let me just get everything drag it inside trap it's wait a few seconds and it will be inside great so we go here uh we'll find over here so we open the scouter sorry the animation sequence you can see uh if I manage this okay so I guess very small but you can see um it playing there okay so the spikes are playing uh now another uh one thing about the S is that it is um the other way around so we have to basically invert it so we have to go into the race scale over here and put it as minus one so now we'll go from you know being in the ground to showing up I don't know why it just inverted okay but it's okay so we can just put it as minus one now it's very small so of course when we place it in a world we have to increase the size okay so now we're gonna do is just right click and create a new blueprint class it's gonna be type actor because it will just be out there in the world and this will be BP underscore use for example trap and now we can go ahead and open this guy up and now we're gonna do is add a component and this will be this hill to mesh which will of course be the um trap itself and now we can find it over here which I think is called yeah tribe so tripe not trap and of course it's very very small so we have to make it uh big so let's go ahead and just lock this and let's play a bit with the size so I guess that we have to go maybe even to a hundred so let's see um okay use Pros there we go I don't know why okay so I'll just unlock this and put 10 10 10. and I think we're getting a better result over here maybe we have to go into 50 at three yeah maybe we have to go and keep this so this will you know completely depend on the size that you want and so on but here we have our cool spikes over here great so now we can compile and save so of course this spice and you know have to only trigger the animation when we are passing um basically over so what we have to do is let's create a trigger so so let's go up here into the slightly parent so it will not Beach out of the skeleton mesh or anything like that and we can just add a new component let's first search for a box Collision let's go ahead and drag it here so this will be a the radius and you can see the square over here so now we can just go ahead and just change the Box extent to fill up the um basically the Trap itself and where we want to start and appear and we can change the set so it's not so high there we go something with its values works so 50 50 and 16 and then 16 of height that works perfectly for me but of course depends on your model or if you're saying the same one it's okay but any scale and things like that great so now when we pass over it we need to play the animation so first let's go ahead and just drag it into the scene to see how the size is and I'm seeing over here that well it is quite small actually so let's go back into the blueprint and another thing I need to do is actually go and get the radius and put a child off the track so now it will go ahead and rescale and depending on or the actual trap let's go ahead and find this around 120 so in all axes of course let's go ahead and just put 120 and now this is something more of what we want great so now basically if we go through it of course these Spikes have to appear and of course they will be hitting when there's no one there okay so we have to do a few things so let's go ahead and basically start off by going ahead and just playing the spikes up your animation when my character goes over so let's go ahead and select the radius uh trigger let's go down in the details panel and we can find this event which is on component begin our lap let's go ahead and click this plus button so we will sign up into event so basically we want to make sure that the other actor entering in this trigger is our character so we're going to do is just cast to third person character of course if you're using any other character blueprint you can use for your one great so now that we are making sure that it is our player who's entering in this trigger what we can do is go ahead and play the animation in it so let's go ahead and get the Trap scale the mesh and we can drag this and say play animation and now this will not need to be an anime Montage or any kind it's much simpler you can just play directly the animation so let's go over here plug it over here let's plug this here and then we can just find the animation that it is which I don't know if it was yes Spike trap hide which of course we inverted it so now it will not be hide you know so there we go so we can actually go ahead and test this out now make sure okay before I press play go into your radius and this will be by default but just to make sure let's go down and make sure that the Collision pretest is in overlap or dynamic because if not it might be in another type of collision a preset that will not detect our player or whatever so it has to be overlap all dynamic so now we press play it will go ahead and you know be out who changed to be hidden but now when we pass over here okay um you can see that it is something pretty strange and of course it's due to the animation so as you can see over here the animation is actually gone ahead and rotated for some reason um in this axis over there um so what we have to do is basically rotate it like this okay so 90 degrees when we play the animation now if you're using any other spike a model maybe you don't have this issue but in in our case we do have decision so we have to move the spike to be like this which will be basically the child so we basically 90 on here so basically on the x-axis let's go ahead and do that let's go ahead and open this and go here select our trap mesh itself and then in rotation we'll put 90. of course you wouldn't want to do this when we play the animation so on here we can set the Trap and then set and rotation and now the rotation will go ahead and be the relative rotation because it's relative to the blueprint itself and now we just want to change the X to be 90 and that's it now you will see that it will go ahead and play correctly without changing uh now the animation did actually not play so let's go ahead and just make sure that um we are only doing this once because maybe it's overlapping so let's go and before we actually play the animation go ahead and just do it once so making sure that it will not repeat multiple times Etc now it will still not go ahead and play so one of the reasons probably is because we have the race scale to zero so sorry to minus one so we were to put it at one you will see that now uh it will actually play as you can see so we cannot directly change from the animations go back and put that into zero so instead of actually just accessing this animation sequence from I'm playing it from the blueprint we need to go ahead and create an animation blueprint for itself now maybe you don't have this issue if you have another model but for our model we sadly need this but hey it's okay let's go ahead into the guidance browser right click and create a new animation blueprint over here now we'll go ahead and select the Trap um skeleton and say k grade ABP underscore trap it will be let's go ahead and open this guy up and now we can put him over here so basically we will need to create a new state just drag it here say State and machine and this will just be honestly the States you know let's go ahead and open this up so basically we'll have a normal state which will be the idle basically um the spikes saved I guess we can call it that like basically they're underground and then we will have another state which will be um spikes oh okay spikes up there we go great so when this goes ahead and triggers we will transition of course right now the you know they'll have the animations on so we will have to go ahead and fill it so another thing that we can do is go and duplicate the spike animation go ahead and duplicate it and call this the spike trap underscore idle let's go ahead and open this and now we're going to do is basically go into the last keyframe and just go a bit into the right so into the left so when it's nearly close right click and then remove frame from 0 to 19. so now we only have this uh still frame so now we can save and close this and we can go into here and just get the idle from the asset browser that if you don't see anything is going to win or found it and then the idle can just put it inside of here and there you go and make sure to select it and put Loop animation now we can go back to the States I know in spikes up we of course have to play this animation over here now the player with we will go ahead and change it from here to be minus one and now we can go ahead and just plug it over here great so now we need to create the transition because of course if not um well we will not be able to go to our spikes let's go a great goal at creating variable uh spikes out I guess we can call it that now it's open here and just drag it here so if it's true it will transition and honestly we don't need to transition back because our specs will only play once and like like that that's why we also had to beat the ones so they don't uh go ahead and save and go outside of course you can change that and just add a new transition backwards and delete this but I just prefer like that great we need to go to the event graph and then go ahead and cast to our BP trap blueprint so um okay and I cast to BP trap there we go and for some reason there we go and now we can put it with their grid um no okay of course because it doesn't inherit for pawns so we cannot delete and we can now delete this I want it to do is basically um also just right click over here and say initialize animation so basically this was just trigger at the start one time so at the beginning play and then on here we will go ahead and get a actor of class and this will be the Trap over here okay great and now uh we can actually go ahead and cast into that octet and then save it as a variable so this will be the BP trap there we go and now when we compile we don't have that error okay and actually we can just directly plug it around and even need the note for casting so there we go it's already give us an output of that type great so now in the update we can just get it trap and then we need to get if if this is true so we can just delete the play animation over here and what we can do is just create a new variable which is um trap up something like that and we're going to get it drag it and then in here we're gonna enable it compile go here and now we can just get the uh get crap up and then set it in spikes out so there's a change it will go ahead and assign it so now that should be working but of course we need to sign it so in here uh we also need to get the Trap which I deleted the one over here just plug it in back and in the viewport we have to slightly trap and now go into the name class and put of course our trap blueprint that we have to create uh now you will see that it's actually rotated so that will mean that we have to rotate it from the start because of course the idle animation will be like that and now I can actually delete this node so actually things will be a bit center now don't worry about the Jew okay we'll remove it in a second but now if I press play you can see that the strap will be basically on the ground and when I pass it will go ahead and appear so everything is going ahead and working pretty pretty well so the only thing left is to go ahead and of course get rid of the duo so go into the idle and the reason is that there's a lot of frames here the candles get a bit more in depth into here into the end and right click and then remove frame to one and they'll all will only be one frame so now as you can see it's not noticeable now there's no jiggle another thing that you can go ahead and do is basically make the the Trap animation and spikes up select it and put the play rate to me minus uh two so actually it will play faster because I guess it was a bit slow so I mean this will depend you but now you can go up there we go and it will disappear good so now we quickly now to go and make the last thing which will be and activate in the Ragdoll for this character so we can do is go ahead and open the third person character real quick I guess it's gonna be the last thing over here yo of course later on you can play sounds of stuff but I will not cover that let's go here and create a new custom event and it's going to be ragdoll okay and now we're going to do is get the mesh and as simple as that are you saying set simulate physics so we'll go ahead and activate all the bones to have physics and simulate take it on and now all we have to do is go into the mesh and go down into the Collision presets and make sure that it is set as physics actor and now we're going to go into the capsule component go a bit up and set the Collision presets to be in or only Pawn so I will not go ahead and collide with its own uh Sharp so now in the try blueprint we can now go here and sorry and get this and then say ragdoll and now when we pass over it it will go ahead and do so now because these traps do have a bit of delay you can add also the label here like the animation itself takes a bit to enter so let's go ahead and just put 8.2 seconds of delay so now you see that I want to enter it spikes out and then I go ahead and right though there we go guys that's it if you found it so helpful I really appreciate if you like the video and subscribe to my channel I have lots of Unreal Engine factors so if you want to go ahead till now go ahead your mind the screw server and follow me on all my instructions such as Discord and sorry disc or not but Twitter and Instagram and so on and now yes with what I said bye bye thank you
Info
Channel: Gorka Games
Views: 13,241
Rating: undefined out of 5
Keywords: games, videojuegos, unreal engine, unreal engine 5, ue5, spike trap, tutorial, quixel, megascans, unreal engine spike trap, trap unreal engine 5, ue5 spike trap, ue5 spike trap tutorial, ue5 how to make a trap, unreal engine 5 trap damages player, unreal engine 5 damage player with trap, unreal engine 5 trap, unreal engine 5 how to trap the player, unreal engine 4, ue4, unreal engine 5 easy trap, ue5 h`trap tutorial, trap spike in ue5
Id: l3mNkcY4I8g
Channel Id: undefined
Length: 15min 54sec (954 seconds)
Published: Mon Mar 06 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.