How to Shoot a Projectile in Unreal Engine 5

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
what's up guys welcome to new umbreal engine factorial and today I'm going to show you on how to make a projectile or a bullet it's going to be a very easy video to follow so let's get started but first check out the link in the description to get out with some Unreal Engine courses on winfox alright so the first thing I'm going to do is go ahead and create a new blueprint class it's going to be of type actor as we're gonna just spawn it in the scene so it's gonna be a BP project dial check for example so let's go ahead and open this guy up so the first component that we're gonna add is just gonna be for example a sphere this will have a you know a mesh to use visualize our uh bullet now of course you can change this into any static mesh that you want for example if you actually have a bullet model or whatever other projectile model that you have you can just plug it in over here so the next components that we're going to need is going to be the projectile movement component so yeah Unreal Engine has actually this in the engine so it's going to be very easy for us to actually make this bullet so the main parameters that we have to focus on is going to be this too initial speed and Max Speed so let's say that initial speed is going to be around 3000 and the max speed is going to be like 3500. so basically um it will start with a speed of 3000 and then it can accelerate into 3 500. of course you can choose whatever values you want I'm just putting some random values just to show you how it works now we have some more options on here of course I will not be covering all of them just really the two main ones you have to cover is an into speed and Max Speed but then you can use um two things as the rotation changes uh between the velocity if it can balance the friction that it has the bounciness ETC so you can go ahead and you know customize it as you want so let's go ahead and just compile and save this and I'm going to go ahead and open my third person character blueprint of course you can use whatever character blueprint you're using if it's first person whatever it doesn't matter now let's make that for example when I press the left Mouse bottom I will go ahead and spawn this projectile so we can use you say spawn actor from class and then we're going to choose the projectile that we have just created so BB product out and then the spawn position is going to be basically one that we provide here so what we're going to do is as simple as gonna add a new component that's going to be an arrow and basically it's going to be the [Music] um projectile spawn bus so basically the projectile will spawn in this point over here and we can just see it better with an arrow so say that it will just spawn just right in front of this player right on this pivot over here and it will be going forward so now what we can do is just get the preto uh spawn pause and then we're gonna get the transform transform and we can just get the weld transform and we can just plug that in into our spawn position and then another thing that we can do is that this to be uh in always spawn ignore collisions just in case there's an obstacle we always want to spawn our bullet of course this is preferable preference but I'm gonna make it like that so now if we go ahead and press play and we actually go ahead and test it out so if I left click you will see that a huge bullet appears in front of my character and it's really working this is really cool now the thing is that it's absolutely huge so we can do is just get the scale and just reduce it quite a lot so for example let's say it's going to be around the scale over here very very small so now what we can do is press play and we will see that the bullet will be much smaller more like an actual bullet you can see looks really cool now the thing is that it's really not like colliding with anything at all so we can just go back into the bullet we can go into the sphere over here go down and you can see that the collisions are actually enabled we have block bolt dynamic the thing is that we have to go into the projectile movement and on here to actually and say that it can interact with things we can say uh what is it go up here and say should bounce and we have to do one more thing we'll go ahead and get the sphere and make it this at the scene root so basically it will be the parent itself so let's go back in here and now if I were to press play and get closer into the wall for example you will see that now it actually bounces now it made my um my ball huge again with my projectile because basically it kind of changed the scale um the thing is that this will not change at all so if I were to change this and then spawn it it would be as normal this is because it is uh changed on here how the transform it is so we're gonna leave this at 111 for example and then we can just go back into the third person character and right click split the transform and split the transform so the location will be location the rotation rotation but the scale will be different so for example point zero uh five or whatever it was what we had on before so basically like this is how you can change a bit the the size and stuff so now we get back into the wall you will see that is much smaller and will actually bounce so it looks really cool and of course maybe have made it too small so you can use both for example point one so something like that and you can play with the values as you want now a last thing I'm going to do is in the projectile I'm gonna go into the on component hit and I'm just gonna get the other actor and then just destroy it destroy actor so then when it will collide with something it will actually go ahead and destroy the actor so if I go and press play get uh linear to this and shoot you will see that the everything just disappeared this is because um it is bouncing and now it's trying so for example getting straight a sector and immediately destroy to the the bullet itself so now we can get the Proctor movement and get should bounce off and then if we go ahead and press play and go into a thing we can now destroy without well it basically destroyed the players so what we can do is just um E-Check over here so basically cast to uh third person characters so we're gonna basically cast into it so if the cast basically failed it means that well it is not a um it is not a oh also I want to unplug this over here and plug this over here wait a second so this one here this one here there we go so we'll be um checking if it's and the the third person character if it's not it will fail so it will destroy what it has collided and then immediately basically the bullet itself so you can see the target itself there so now if we go and press play you will see that I can go and the player will not be destroyed but uh what we impact yes so yeah you can do a lot of stuff with this and play around with it so that's it guys if you enjoyed the tour and found it helpful I really appreciate you look at that video And subscribe to my channel I have lots of Unreal Engine factors this one so if you want to check out awesome courses I have the links in the description and without said bye bye [Music]
Info
Channel: Gorka Games
Views: 25,369
Rating: undefined out of 5
Keywords: games, videojuegos, unreal engine, unreal engine 5, ue5, shoot projectile, tutorial, quixel, megascans, unreal engine shoot projectile, shoot ptojectile unreal engine 5, ue5 shoot projectile, ue5 make projectile tutorial, ue5 how to make a projectile, unreal engine 5 bullet system, unreal engine 5 shoot simple projectile, unreal engine 5 how to create a projectile, unreal engine 4, ue4, unreal engine 5 simple bullet tutorial, ue5 shoot bullet tutorial, simple projectile system in ue5
Id: -4Kl2FY1_-4
Channel Id: undefined
Length: 7min 53sec (473 seconds)
Published: Thu Dec 08 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.