UNITY - 3RD PERSON PLAYER - PREVENT CLIPPING CAMERA GOING THROUGH WALLS

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Applause] [Music] all right guys and welcome back to hypershade tutorials in today's tutorial we're going to be preventing the camera going for the walls and also we're going to be making the camera follow the character so if we run and move our camera quite fast it'll catch up back to the player so if you're not sure if you notice that but if you noticed it zooms back onto the character so if i run around for a bit see it kind of focuses back on that character and also we're going to prevent in the camera going through the walls so if i go up to this wall and rotate my camera around we're going to get the following effect didn't work as quite as good over there but we can adjust the there we go so let's hit in the wall and it's not letting the camera go through that's what we're going to be covering today it's quite easy and let's get on with it right for this tutorial all you need to do is click on your free look cam and go at the very bottom where it says extensions and add a cinemachine collider go to extensions again and add a cinemachine follow zoom now let's prevent the camera from going through the warm so let's set the variables so clyde against we're going to say everything okay um ignore tags we want to ignore the player we don't want our camera to be going through the player the minimum distance i'm going to leave as 0.01 avoid obstacles we need ticked distance limit i'm going to leave zero for now we can adjust that while we're in game um camera radius i'm gonna set to zero and i'm gonna set this one to preserve camera height like so as for the maximum effort i'm gonna set this to four as it is and damping i'm not going to damp anything it's up to you i'll show you what that does live and the optimal target distance will leave zero as well now for the camera follow i'm gonna set my damping sorry width a bit wider so if i increase this you'll see it go like that that's looking a bit more nice and starts to give you that third person feel for the damping i'm gonna put six uh the minimum field of view i'm gonna put 31 or 30 let's just keep it round numbers and for the field of view max i'm going to keep it 60. let's save this let's run our game and let's see what happens right so if i move the camera just even moving it you see that the camera starts to pan into the character not sure if you can see that so well but if you do on your own end you'll be able to see what i'm talking about and i quite like that effect it stays up to date with the character and it follows it perfect even in the jump is doing a better job good i'm just going to unclick from the character so i have something else selected so we can see a bit more smoother there we go now let's test the wall colliding so i'm going around there you go as you can see as soon as i get next to the wall it kicks the camera inwards and keep him around the player and that's how you keep the camera contained and close to the character now there are some wearables you can mock around with there is damping for example you can have damping if you wish i don't wanna personally don't like it because that's why it kind of makes it go through the walls and i don't like that as much but let's see if we can prevent that also so um [Music] not really i'm not what i can see yeah i don't like the damping as much so maybe if i bring it down a bit i'm gonna put this back to zero apologies that's actually okay we can leave the damping to 0.74 just to give it some kind of nice smooth effect as well there we go it's not too bad okay let's try that on these walls there we go it's actually it's looking quite smooth i like that oh that's fantastic that is um there you have it guys that's how you prevent the camera from going through the walls and that's how you make the camera also follow your character and give it a nice effect this has been happy to tutorials thank you so much for watching this video catch you next time
Info
Channel: HyperShadeTutorials
Views: 17,380
Rating: undefined out of 5
Keywords: Unity, 3d, C++, C+, CSharp, unity, tutorial, FPS, firts, person, shooter, tutorials, Unity 3d, 3D, FPS Shooter, Tutorials, Unity 3d Tutorials, camera clipping, camera through walls, unity camera, third person cam, third person camera
Id: zfgp6EIZfBU
Channel Id: undefined
Length: 5min 35sec (335 seconds)
Published: Wed Feb 17 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.