Simple RTS Camera in Unreal Engine 5.3

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
all right so today we're going to be creating a simple RTS W ASD camera we're going to use the Unreal Engine 5 enhanced input and so to do this let's first set up a blank project we're going to select Blueprints and don't select any of the starter content you can name it whatever you want and let's create it so now that we have our level loaded let's jump into jump into this and and get right down into near the ground and what we're going to do is first set up a simple Cube just so we have a reference so to do that to do that let's hit our blueprint class we're going to create an actor just name this Cube jump into that and if you hit add and then search for a cube just get a basic shape hit save there compile jump back here go to our content drawer and we can drag that out there and let's just save this map perfect so the next thing we're going to do is create a simple actor sorry a simple Pawn that's going to represent our camera that we're going to actually control so let's right click this hit blueprint select Pawn if we type in Blueprint player so my it we have now a pawn class here and let's set that up so the first thing we're going to do is set up the camera so to do that let's add a spring arm uh which is going to be the arm that the camera actually uh is attached to and since against so if we see that here let's set the the arm length 1,200 looks good and now let's add a camera to it we search for camera we see this is our hierarchy our camera out here and what we're going to do is we're going to rotate this spring arm so let's rotate this about 50 degrees to get that RTS feel perfect and the other thing that we need in order to actually make this movable is add a um movement class floating Pond movement class to our uh pawn and this will allow us to actually uh control it so we compile there great we're well on our way so let's add this to our map so we can see it drag this out let's Orient this in our world okay so we see the cube now on this if you select uh the blueprint player that we we just added and if you scroll down to the pawn settings here in the details pane you see this autop possessed player option we're going to select player zero and now when we hit play uh we take control of that and we can see our Cube for reference so right now when I hit WD nothing happens and we're going to enable that now so in order to do that we're going to leverage the new enhanced input system from Unreal Engine and we're going to need to set a couple things up in order to make that work so if you go to your content browser content drawer and you right click and you go to input you'll see an option here for our input context and this is what we're going to set up for our W ASD let's go input IMC base input and if we jump into that we see this option to have mappings uh where we could map our keys if we add one we'll see that we don't have anything that we can add yet so we need to create this this is our input action this is going to represent hold essentially the logic um for our WD Keys it's going to group them together so let's create that let's go to content drawer right click under input let's go to input action we're going to go I a move if we jump into that uh we have a couple options here but the one that we're concerned with now is this value type if you go to Value type and hit AIS 2D this is going to give us information uh this is going to actually return a vector when it's triggered and we can parse this Vector in order to determine the direction that was pressed so we hit save jump back to our base input context and we select our mapping that we added we now see an option for input action to move so let's add that and if we expand if we hit this plus we can now add a control binding so let's expand that okay so we have an option here so this is where we're going to actually set up our WD logic so the first one we'll set up is our W so our forward so if you hit this keyboard option and hit W you now have an option to move that that's going to bind it to W and now under modifier what we want to do is we want to select the Swizzle input axis value and this is going to be useful for actually extracting our uh the value that we need so next let's do our back so let's hit s and we're going to do something similar but instead of swizzling we're first going to negate and then we are going to at a second we're going to Swizzle okay this is good so let's first test let's get this working uh for our wns and then we'll come back and add our A and D so we jump into our player and you go to the blueprint the first thing we're going to do is actually set up our input mapping so we this input map that we created we need to now actually add that uh when the game loads so the first thing we'll do is if you search for get player controller let's get the player controller that we have we're going to need this begin Play We drag this pin out for the return value search for enhanced input you'll see an option here so we'll connect that up and now we with the return value there we'll add a mapping context and the mapping context is going to be the one that we just created so let's select that there you'll see the base input option that we selected and if you in your begin play if you drag this out we have now let's make a comment to make this a little bit easier to read so add mapping input mapping we now have set up we now have added our context so now we actually have to move the player in response so let's do that right here so you right click and you go you search for I am move this is the input action we created for our WD there's an event and if we have the you'll see a few options here we're only going to focus on the return value today so if you right click hit split you'll see an X and A Y and we did set up the Y value value first so let's just make sure that's working so here let's print that to the screen so we'll go to string and then let's print that Search print string and then have this execute oops how this execute when it is first triggered great so let's save that compile jump back to our map and now when I hit W or S we should see value be written to the screen play and now when I hit w we see a one and when I hit s we see a negative one and this is going to represent the forward and backward directions but now we actually have to connect this and actually move the pawn so let's do that let's jump into our player delete these two and now let's if you search for add movement input so we're going to take that y value drag it here and now we're going to need a reference for the world Direction so what we're going to do is we're going to get the the orientation of our actor so let's right click and if we type get forward Vector oops that is not what we want we want get actor forward Vector this is going to be our orientation and we drag that to our word world value we'll be now moving when we hit our W sorry W and S so let's hit save go back to our map hit play and now when we hit W and S we move forward and backward so we're almost there it's pretty cool so what we're going to do now is set up our A and D so if we go back to our base input we need to add those so to do that let's first add our a hit there hit our key press a and now select negate and then if we do another one for D we don't actually have to change anything in this one so we are good to go let's save that jump back to our player and we're almost done let's add another movement input drag that connect this select our x value from our event drag that into the scale and instead of the uh forward Vector we want the right get actor right vector and we drag that there compile hit save go to our map press play we now have our left and right working so now we have the basis of our WD camera for an RTS game so in our next video we're going to focus on creating the zoom and uh enhancing this a little bit so we'll see you there
Info
Channel: Unreal Engine With Matt
Views: 589
Rating: undefined out of 5
Keywords: unreal engine, unreal engine 5, unreal engine rts, unreal engine camera, unreal engine rts camera, unreal engine 5 tutorial, unreal engine 5.3 camera, WASD Camera, Unreal engine 5.3, ue5 rts camera, enhanced input unreal engine, unreal engine 5 enhanced input camera
Id: OMQmPic1jBo
Channel Id: undefined
Length: 11min 19sec (679 seconds)
Published: Mon Mar 04 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.