How To Change Camera Pitch On Zoom in Unreal Engine 4 - UE4 RTS / City Builder Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello and welcome to this video uh in this video it's just a bit of a follow-up to my last one which is the rts city builder camera uh video a user on reddit uh called nomiscz asked what could i do the next step which is zoom that changes distance and pitch at the same time you zoom out you see from above zoom in you're facing the building league of legends has it and what i've got working is this so as you can see we're at the normal kind of pitch and then when we go below a certain threshold the camera tilts down there to face sort of your units or the buildings or whatever you've got on the ground there just would see it better i'll just quickly add in a cube hit play come down here as we zoom in and we get nice up and close and personal um it's really simple to do so i'm just gonna i've already done it this won't be a step-by-step thing it'll just be walking through exactly what i've done and showing the nodes though so again if you haven't seen the last video i'll link it above but the the concept is pretty much the same so basically i've got a camera zoom function so when i scroll the wheel the camera zooms in uh the way this works is it interpolates between its current position and the new target and then it sets the target arm length of our spring arm here and then after that to get the pitch shift working um i have a branch here and we're basically checking is this target arm length that we're going to go to when we zoom in is this less than the pitch threshold which i've currently set um in my event graph on begin play i've set my pitch threshold to be a quarter of whatever our maximum zoom level is so that's currently 600 so if our zoom goes less than 200 units so essentially if our spring arm becomes less than 200 units then our pitch will shift to -40 and it'll do it smoothly let me just undo those so if the new target arm length of the spring arm is less than the pitch threshold and that's true we're going to go up to an interp 2 here if it's true we're going to set the relative rotation of our spring arm and we're going to take our current spring arm pitch and we're going to interpolate over a set speed to our cam low pitch which is a variable i've set down here and it's minus 40. i got that by um if you see where it sort of minus 69 that should be minus 70 i don't know why it's gone to that just do minus 70. um so this is how our high cam high pitch and then over tilt this down to minus 40 this is our low pitch so we're going to go from our current pitch whatever that that may be and we could probably just plug in our high pitch into here but this just makes sure that this there's not going to be any jumping so we're going to take the exact value of our current pitch and move it towards our low pitch over our interp speed you can change this you can make it faster or slower so for example if i did this 0.5 and press play as you go down you can see it slowly zooms in which you may or may not want i don't particularly like that it's a bit too slow um i found eight works quite well it's just a nice kind of zoom down and then to have it going the other way as we change our target arm length if we check our target arm length and if it if it's less than the pitch threshold and that's full so basically if the new target arm length is greater than the pitch threshold then we're going to do the exact same thing we're going to get our current pitch set the relative rotation of our spring arm and then we're going to interpolate to our high pitch which again we've set as a variable down here minus 70 and then we're gonna interpolate back at the same sort of speed that's pretty much all there is to it actually it's really simple really effective it works kind of at any angle because we're doing it relative to the pawn and yeah that's that's it a nice simple addition to the rts slash that you build the camera movement in the last one i'm gonna update the project files on my patreon to include this new um this new branch this new functionality uh the link to the patreon is down below if you found this video helpful in any way it'd be great if you could give the video a like and consider subscribing if you're not already that's everything for now and i will catch you guys in the next one bye
Info
Channel: Dan Pos
Views: 1,744
Rating: undefined out of 5
Keywords: game dev, game design, unreal engine tutorials, ue4 tutorials, unreal engine 4 games, game development, game development tutorial, game design basics, unreal engine rts tutorial, unreal engine city builder tutorial
Id: ZOcnKUh3PV4
Channel Id: undefined
Length: 4min 31sec (271 seconds)
Published: Sun Jan 17 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.