Glide Camera Between First And Third Person | Smooth Transition - Unreal Engine 4 Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey guys welcome back to another relationship tutorial today i'll be showing you how to change perspectives from third to first person and have the camera smoothly transition and glide between those two points so instead of it just cutting between them like in a previous tutorial this one will glide between those two smoothly and it will look really nice so i'll show you here what we're going to make so you can see we're in the third person here we can move about if we press change perspective it zooms into the head here we can move about perfectly like this press it again it goes out and this works all perfectly like so again goes in like that and comes out again like that and you can change how long this will take perfect for you you can customize it completely so i'll show you how to do that now so i'll just delete everything that i've done and we'll restart right so now that i've deleted everything we'll start so what we're going to do is open up our third person character blueprint here so for me this is content third person bp blueprints third person character this is basically just your character so it could be third person first person or whatever you've named it and so once that's opened we're gonna go straight up to the viewport up here and what we're gonna do first is create our first person camera as well as our third so as you can see we've already got our third passing camera here and now we're gonna create the first if you've already done this you can skip further ahead but i'm going to show you how so we just select this camera here it's probably called follow camera for you but i already renamed it to tpp camera for third person perspective so if you hit ctrl c ctrl v to duplicate that i'm going to call this fpp camera for first person perspective and if we just drag and drop that onto the mesh there so it is a parent of the mesh and the parent socket over here on the right we just choose head this means it's now parented to the head of our player as we want it as it is the first person camera so if we then rotate it and just move it to where we want it on the player i think this will be good and one final thing we need to do here it's down here we need to take use pawn control rotation and that is now the first person camera setup so we have our first person and third person camera now one thing i'm going to do as i want to start in the third person rather than first i'm going to come down here so get some space get an event begin play get a reference to your third person and first person camera off third person drag out set active new active and then off first person drag out set active or duplicate that last one and set this to not active now this isn't a necessary step this is just how i want to do it as i want it to start in third person first so i think that's good for me so i'll hit compile and go back to the viewport again now what we're going to do again is create another camera so if we go add component and get a camera i'm just going to call this ref tpp as what it says is it is a reference for the third bison camera so as we are going to be moving the third person camera we want to see where we want to put it back so we're not actually going to be using this this is again just reference for location so a good spot i found earlier while testing this was 300 on the x and 80 on the z so that's just where i want it so you can choose this you can just put this where if you want this is just essentially where the camera is going to go back to once it's finished the transition from going first to third and then one final thing we're going to do in the viewport here is create three new variables these are all going to be vectors so we hit plus variable down here this one is going to be called tpp location and this is going to be a vector obviously this is the location for the third person camera get another one fpp location again vector this is the first plastic camera location and now tpp original which is going to be the original point of the camera i.e this one here so where we want the camera to go back to so we hit compile on that what we're going to do next is go to the event graph and now we're going to start putting in the code so if you find some space we're going to do is actually change the camera perspective so to make this easier for us what we can do is minimize this go to edit project settings if we go to input we can create an action mapping down here plus action mappings i'm going to call this one change perspective i'm going to set this to the v key you can set this to whatever you want or call the way if you want it doesn't matter what this basically is is we're creating a custom event so that if you press the buttons you put in here it will fire off that event and that line of code and this is good because then you can add multiple buttons for different consoles and stuff like that and you can also do keybinding in here so once you've done that we'll close that and go back to the blueprint we'll right click and search what we just named it so i could call mine change perspective there you go as our event now in there and so the first step off of this is come off of the pressed and we're just going to get a flip-flop here like so and these can go into a timeline so off of a we're going to add timeline like so i'm just going to name this change camera or something along those lines it doesn't matter too much and if we just double click this to open it up we're going to do is up in the top left here we're going to add a float track again i'm just going to call this change camera the names don't mind too much it's just for you and the length up here is how long it's going to be to transition so i think i want mine to last around three seconds so i'm going to leave it as that and then what i'm going to do is right click on the graph add key to curve float there the time will be zero the value will be zero and this is adding a keyframe at the start of the transition if we right click again add key with time 3 and this is going to be the time for how long it is so my length is 3 so i'm going to set it to 3 value of 1 as this means it is now finished hit zoom to fit horizontal zoom fit vertical you can see this graph so this is basically the transition line and the graph where the camera is going to be here going to here so third person to first person so that's done so we can compile and close that change camera timeline there and after you change camera we're going to go into a lap and we're going to be using these vectors we made earlier so what we actually need to do for these vectors is set them so what we're going to do of that is use the event tick to do that so we go up here get some more space and get an event tick node like so we simply just drag on those locations onto there to set them so set tpp location set fpp location and set tpp original like so now obviously we want to put in the according cameras into here so if we just get a reference to all these cameras here like so you can select and drag and drop them all into here tpp is here drag off of it get world location and plug that into this set there and do the same for all of these and so again this is setting the location of them so that the timelines and everything know where the cameras need to move to in real time and so if we do fpp again get world location and plug into there and the reason we're doing this off of event take and not even begin play is because this is also the location in the world not just in a player blueprint so if you just do it once it will always do it to the same spot in the world so get weld location and plug it in there like so now we should be all good for those so we hit compile we now have those variables set accordingly so if we go back down here to the timeline i'll just move this up a little bit we're going to do is just right click here and get a lerp vector like so the alpha will be this change camera here that we just made that's our timeline the a will be the tpp location and the b will be the fpp location like so and again the alpha is that timeline there and so what this is doing is it's going between the value for the third person camera to the first person camera and this timeline is the alpha showing it which value it needs to be at between those two values there so what we can do is get another reference to our third person perspective camera so again drag in tpp camera drag off this and set world location as like i said earlier this is the one we want to be moving so the location of this is going to be the return value off of this lerp it's again that's getting the location and then this is going to go into update as we want to do this every time we update the timeline there so when the timeline is running it's going to be updating the camera's location and then when we're finished this is where we just want to put our normal code for changing the camera so this one's going to be changing to first person for me so what we're going to do is get a reference to the first and third person cameras there i just drag them in like that what we do is third person set active plug that into the finished of the timeline like so get third person there you can also use this one up here but i just like to keep it organized like this first person again set active plug that into there this one we are going to tick so again leave third person unticked first person ticked and then off of this what we can do is set use controller rotation your meaning that it will actually use the mouse control of the yaw to move the camera as well so if we hit compile that's this part done we also want to make sure that the a goes into play from start not just from play as we want to play it from the start of the animation not just where we left it off which is very important later on so again hit compile that's this part done so now we want to do is basically just copy this but for reversing it so going from first to third so like i say it's basically copying it so what we all can do is actually just duplicate this and then we'll just change some of the values so we just duplicate it down there plug the b into reverse from end this time so now we are reversing it and from the end as obviously this timeline is to go from third to first this is now reversing it so it's going from first to third and obviously it's going back to timeline zero so you can rename this to change camera two like that and we don't need the flip flop there it's my bad so that works like so now again we do need a lot but this time we want instead of the tpp location fpp location we'll delete those we want tpp original in the a as we want to be putting this back to the original point of the camera and then normal tpp location as that is where the camera is now so these are two values we want to be going in between and again this is going into the set world location down here and it's still the third person camera and this is still off of updated like so except this isn't all finished anymore so if we alt left click on that to disconnect that and then plug the set active into the change camera like so and then we'll just switch these around so new active on third person not new active on first and we are not using the control rotation your so it should look something like this and there's also one extra step as well so after the use controller rotation your what we want to do is get a reference to the character movement so drag and drop that in there and we're just going to simply disable movement plug that in there and then we're also going to disable the input of the character so disable input target get player character and you can't just use self otherwise that will do the whole blueprint which is not what we want and player controller is get player controller the reason we're doing this is because otherwise if you are moving the camera location will be off so when the camera goes back to third person it won't be in the right position and it will just look really bad so what we also want to do is re-enable it once it's finished so out of the finished back of the timeline down here what we're going to do is set movement mode so we need the catch movement again set movement mode like so set this back to walking like that choose new movement mode walking and again enable input like so target can be self this time or you can put it back to player character and then again player controller is get player controller like so if we hit compile now this should be done so if we hit compile again like that save minimize and hit play to test this and move around if we hit one or whatever you set it to so i should set one to v sorry if we hit that we go in so we transition to this camera we can move around perfectly this all works as a first person camera should if we hit it again it goes back out now that didn't actually play the transition as you saw it just popped out so we'll see why it does that so if we go back in here let's have a look so yeah that's my bad these need to be the way around we need to enable the input before we set the movement mode if we just disconnect those and turn them around so we enable input off the finished and then out of enable input we set movement mode like this this should now hopefully fix our issue and also here sorry off the lap i mistakenly put tpp original instead of tpp location so i did say to do that so you probably didn't make that mistake however i must have just read it wrong in the moment so like this off the left tpp original in a tpp location and b enable input offer finished and then set movement mode so this should now be working so let's test this again compile save minimize hit play to test we can move around perfectly if we hit v the camera transitions into first person and we can move around perfectly like this works as a first-person camera should we hit v again the transition goes back out works perfectly and we can move around the camera as the third person one should and this works perfectly so i'll show you again if we hit v it goes in can move around normally all works great if we go back out this again works perfectly like so so i think that'll be it for this video so we've done everything we want to do we've set it so we can go between first and third person and we have a very smooth very nice looking transition going between those as well so i'll show you again we hear v we go in and move around normally we hit it again we go out so thanks so much for watching i hope you enjoyed it found it helpful and if you did make sure to like subscribe down below so thanks so much for watching and i'll see in the next one
Info
Channel: Matt Aspland
Views: 25,883
Rating: undefined out of 5
Keywords: ue4, unreal engine 4, unreal engine, tutorial, ue4 tutorial, unreal engine 4 tutorial, how to make a game, how to, 3d modelling, blender, games design, ue5, unreal engine 5, tpp, fpp, third person, first person, fps, camera, perspective, toggle, toggle between third person and first person, tpp to fpp, third person to first person, key press, v key, how to toggle, how to change, change, to, smooth, transition, between, glide, locations, animation, timeline, animations, 1st, 3rd, start, flip flop
Id: CW59e1SEvWo
Channel Id: undefined
Length: 13min 35sec (815 seconds)
Published: Mon Sep 21 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.