Create an RTS Move Marker in Unreal Engine 5+

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello everyone in this video we're going to create a simple move marker that works on slope terrain as well just something to show where the character is moving to and gets cleaned up when he arrives to start on our move marker we're going to create a material I'm going to just put it in this materials folder here create a new material call it in marker open it up and the first thing we'll do is we'll set it to a deferred decal because it's going to be a deca and then we'll make it translucent I'll just hold three on the keyboard and click to add a color and change this to a parameter this will be the color I'm going to make it a and I'm going to create a old s and click to add a parameter and I'm going to call this intensity this will be like well you could call it Glow I guess if if you ramp up the intensity enough I'm going to multiply those change this to 20 for now let's change this to a square that's good all right so we want to make this a radial so we're going to create a radial gradient and we'll just duplicate this because we're going to create a band with it so we're going to subtract and from the other preview this at the moment it's not doing anything because they're both the same so we're basically canceling each other out what we want to do is create some parameters so holding s again on our radius another one call it sharpness so the radius we're going to put into the bottom one and we'll set this to or not E4 you can see that's so that's now subtracting from the other one correctly but it's really blurry and crappy so that's what we want this sharpness so I'm going to crack this up really high and I'll put this into the densities and that's clean that up a bit what I want to do now actually I'll hook this up so to hook hook this up we can just stop previewing that and put this into the opacity and that gives us our shape so what are if you just want to ring that that's fine you can just just use that but what I want to do is I want to I want to make it a bit more subtitled I don't want a really big bright ring and you can or you can change the thickness here to you know make it make it thinner or or whatever but the I'm going to just cut it down a bit and make it not so obvious and there's there's a texture you get with the top down the level prototyping here so it's just a simple grid texture so I'm going to bring this in and what I'm going to do is I'm going to multiply holding m add a multiplier I'm going to use the red Channel I'm going to multiply that before I put it into the opacity and that just gives me the outer thing so the grid is sort of acting as a as an opacity mask on over over the over the actual ring so what I want to do now is again this is optional I want to make it like throb over time so and add a time node I'm actually going to have a scalar for time this will be how how fast it sort of goes on and off let's call it speed change this to five so we now we need a linear sine wave this will give us the sort of the on and off on and off this is the standard sine wave that's what it is so time will go into the bay there and our speed will go into the period and this option here lets it go from negative one to one rather from zero to one so we want to make this true so I'm just going to drag off this and just add a so I don't need to be a parameter static ball and we'll turn that on to true I'll show the difference of that so this will go into our density so we'll add a multiplier here and we'll bring this into here place this there we go we've got a bit of a flash going on what okay I might up the intensity because it's so small now I might make this ridiculous it's really got a glow to it there if you take this off you can see it sort of glows but it never goes away so that that's what that is adding it's adding that negative a so it sort of goes away to nothing and then back all right let's done I'll Make an instance of that and now we just need a an actor for it so I'm not actually putting everything in here is I'll do it in here it's just a generic actor and we'll call this B uh move marker so now we need to add our decal to this so we just need add a decal component and add our material to that so we want that marker material instance so this is going to need a rotation of 90 on the pitch I'm going to put it on now but we'll need to take it off because I'll I'll show you later why but I'll just put it on now so we can see it so that's obviously too massive uh where's the size so here let's make it half that size how does that look yeah very good I hope that again yeah that should do for a for a character all right so like I said I'm going to take that rotation out because what we're going to do is we're going to allow for slopes of hills and things and we'll need to apply this rotation after we calculate the rotation of the slope so what we'll do is we'll just reset this to zero and then we'll come into the begin play we could do this in C plus plus one it's just so simple I'm just going to do it here so we're going to get the decal and we're going to set the world rotation of that and then we'll get the actor rotation so that's all we need there for that so what that's doing is it's going to get the actor rotation so our our move marker actor and set the decal component to the same rotation as the actor so what we can do now in the code when we figure out where we're going to place it we can get the terrain rotation and just rotate the actor and it's going to automatically rotate the decal foreign start setting that up so we'll put this in our now move section our Command section since it's going to be part of that we're going to need a a reference to that class so the the blueprint that we just made the move marker class so put that down here and that's just so you're saying that it's going to be a class of actor that we're going to have here and we'll call it move like a class and then we're actually going to need a a reference to the move marker when we actually spawn it and we're obviously going to need a function to spawn it so let's call that set move marker we're going to pass in the location that we want to spawn it so in here we just need to check that that class that we're we've actually assigned it in the editor to to our character because it'll be a variable on our character now what we want to do is check if this character already has a move marker then we want to get rid of it because we're now we're setting the move marker we could actually check if it exists and move it around rather than spawn it all the time probably more performance but for now we're just going to destroy it and go on to creating a new one so we're going to need some parameters to spawn our new actor so we're just saying this is the instigator and always spawn it so they don't have to worry about Collision or anything like that we're going to need a reference to the world need a reference to the world every time you spawn an actor so we're going to make sure we've got that and then we're going to place this actor in in our move marker variable and we're going to use the spawn actor function so the class we're going to spawn is our our class that we're ever signed and the location is not going to be directly this will be the location as in the vector what we need here is we want to we want to get a transform of the terrain so that it will be the position and the rotation so we're going to create a new function for that and we'll just make that a public one up here actually it doesn't need to be public protected so like a generic function that we could use for other things so this is going to be a similar setup to our line traces we've done in other areas so the position or the location that I'm passing in I'm going to get a start Trace position and an end Trace position again check that we've got a world contacts or you know the world reference and then we're going to do our our line Trace so we're using it we're passing in our hit result starting at the line Trace ending at the trace end so we're trying to hit the terrain here and we've got this custom channel here for uh the terrain I'm not sure if we'll need to we may you need to use visibility on that if we want to walk on platforms and things like that like we've got in the test map but we do just terrain for now and then we're just passing in a generic Collision parameters there we don't really need anything in that and then if we hit something which you'd hope we would but we just need to check that we do hit something we'll we need to create a new transform from that hit so this will be what we're going to return I forgot to mention we're going to return a full transform out of this function and if we don't hit anything we need to return um there's a there's a thing called transform identity which is basically like you know an empty transform zero values all right so in here we want to we want to fill out this hit transform so the first thing we're going to do is set the location and what we'll do with the location is we're also going to use the hit impact point but we want to what we'll do is we'll just lift it up a bit so we've got like grass or anything like that like it's just up a bit we'll make sure the decal doesn't flicker in if it's in the ground too much like that so we'll just I'm just going to add a little bit of a 0.25 above what it um what the ground actually is and so that's our location and now we need to get the rotation so we'll create a new and a variable for our rotation here and then we'll what we need to do is get the normal of the terrain so which which direction is up for the terrain and basically make a rotator out of that compared to the normal up so that'll give us a rotation on the X as to where we're facing sort of thing so we're rotating around the Z up Vector so now we need to add that 90 pitch that we're talking about so we've set it to the right rotation but now we just need to add the picture of 90 so it puts the decal on the side so it's at the right presentation angle and then we'll set the rotation and it has to be a quaternion so we can in this the function that transforms that rotation into a quaternion for us and we'll so we're setting the rotation on our transform uh we don't need a set scale scale is not going to change so that's fine to leave as it is and that's our transform coming back so now we can take this function back down to our our spawn active here we can get transform of our location that we passed in and then the last thing is we just passing out params which is default anyway so that should create our move marker angled to the terrain where we want it so now we need to call this somewhere we're going to call this when we order the move so we're going to go to command move which is yeah so after the we've sent the move off we'll set the move marker and we're passing in the location from the command data is where we clicked and the other one we want to do is in the destination reached if we do have a move marker we want to destroy it so that when the character arrives at their destination we destroy the move marker and like I said before the other option here is just to hide it and make it visible again and not spawn it and move it instead of creating it all the time just move it around but it's not a massive process it'll be a different story if you've got you know 100 units or something I'm going to keep in mind later so let's go back to the editor right now back in the editor we want to go to our character we need just need to add that marker reference AI settings category B move marker foreign move we should get a nice marker deletes when he arrives and if we try and go up a hill it should be curved to the hill they could make it but close enough what I was saying before is we might have troubles going up onto stuff so we might have to change he's going up there but if I click up here it's going through to the terrain it's not seeing this platform so if you've got stuff like this in your game you might have to use a separate either use visibility Channel or you might have to create a separate Channel and include things that you want to walk on because with the visibility Channel you'll be able to like click on the top of these towers and on boxes if you just use visibility other than that that is simple move marker please don't forget to like if you found this tutorial helpful and subscribe so you don't miss out on future tutorials you can join me on Discord or sign up to my patreon where you can get access to all my tutorials early and the project files as well as gain access to behind the scenes on my current game development if you have any questions leave them in the comments thank you for watching see you next time [Music] thank you
Info
Channel: Rogue Entity
Views: 778
Rating: undefined out of 5
Keywords: UE4, UE5, UE5.1, Tutorial, Programming, C++, Game, Gaming, Game Design, Game Programming, Game Audio, Game Art, Game Testing Game Engine, Game Production, Game Industry, Unreal Engine, Game Development, RTS, Move, Marker, Move Marker, Waypoint, Decal
Id: 0AzFZGaezmw
Channel Id: undefined
Length: 16min 32sec (992 seconds)
Published: Thu Jun 01 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.