THIRD PERSON MOVEMENT in 11 MINUTES - Unity Tutorial
HTML-код
- Опубликовано: 11 июн 2022
- THIRD PERSON MOVEMENT in 11 MINUTES - Unity Tutorial
In this video I'm going to show you how to code full third person rigidbody movement. You can use this character controller as final movement for your game or use my other tutorials to build things like wall running, climbing, sliding, crouching and much more on top of it. (And of course you can also extend this controller yourself if you want)
If this tutorial has helped you in any way, I would really appreciate it if you leave a like in return. And you can also subscribe to this channel if you want to see more tutorials like this one.
Links:
➤ DOWNLOAD the SCRIPT: www.mediafire.com/file/85mzc8...
➤ DOWNLOAD the PROJECT (in the free-code-dave channel): / discord
➤ DON'T CLICK: bit.ly/2VcrDZt
➡️ Get Access to my full MOVEMENT LAB! ➡️
➤ Trailer: • MOVEMENT LAB - Unity P...
🏹 Get Access to my RANGED COMBAT LAB! 🏹
➤ Trailer: • RANGED COMBAT LAB - Un...
Other interesting videos :D
➤ THROWING Grenades, Knives and Other Objects - Unity Tutorial): • THROWING Grenades, Kni...
➤ FULL 3D ENEMY AI in 6 MINUTES! || Unity Tutorial: • FULL 3D ENEMY AI in 6 ...
Support me on Patreon:
➤ / davegamedevelopment
#UnityMovement #ThirdPersonMovement #UnityTutorial
If you need help with any of the code shown, just visit the "coding-help" channel on my discord server :D
Also you can find many more movement tutorials on my channel in the "Tutorials!" playlist - I really hope they help you on your further GameDev journey!
And in case you're interested in getting access to my full MOVEMENT LAB, where I combined all of the movement abilities shown in the tutorials and some more, check out the trailer:
➡ MLab Trailer: ruclips.net/video/9_Q9UxK7VF8/видео.html
Also, since I know lot's of you are interested in ranged combat as well - I can gladly announce that I'm about to release my RANGED COMBAT LAB as well:
🏹 RcLab Trailer: ruclips.net/video/j2YplilHjCA/видео.html
Thanks so much for watching, hope this tutorial has helped you!
Cinemachiene isn't popping up at the top of the screen
@@Scifics You probably have a newer version of cinemachine. Right click in the hierarchy tab and then press cinemachine instead.
@@Scifics GameObject > Cinemachine
Hey man i was really wondering when you are going to use late update functions and delta.time and etc stuff for pdocut ready quality scripts? Would be nice to see it
are you Brackey?
For anyone having a hard time at 4:40, because of "Camera Holder" and "PlayerCam", you put the code on the ThirdPersonCamera, the other cams are from another tutorial.
thanks
So you're saying I put the code in the cinemachine camera?
thank you. i was stuck in this and do trial and error. even try to create empty script that place inside camera but still have problem. but now all fixed
help me
@@haydendev what do you need?
I just want to let you know that, as a college student trying to accomplish my childhood dreams, you helped so much by teaching me tons of useful coding examples. Everything is in such high quality and easy to understand. Thank you so much for your guide.
So glad to hear that! Thanks for watching and best of luck with your dream game!
This was great and you gave us the cherry on top of telling us how we could potentially mess up if we follow your other tutorials. Brilliant.
I’m having a very hard time with this tutorial because of the hierarchy setup and just the sudden appearance of all of these parts is super confusing if you could just have a breakdown on how you put all of those components into it the toutorial would be a lot more helpful becuase I just can’t go off of the sudden appearance of all of these components and I have no experience so please excuse me if this seems like something everyone would already know
If you are having a hard time with that, maybe this tutorial is just too hard for you. Try getting more comfortable with unity before following this tutorial.
@@galaxyshorts7869 I think they are talking about when the orientation object suddenly appears with no explanation
@@galaxyshorts7869 I have 5 years experience in Unity and I'm having a hard time following along. It's because of the way he did it. There's another tutorial that should be followed first. And @theg.o.a.t100 should be following that, if only he linked to it in his bio like he mentioned he would do.
on the First Person Movement he goes over it a bit, really helped me out when he mentioned the movement stuff that i needed
Wow, this is gem. All in one covered in single video. Not too fast, not too slow, easy to pickup. Very nice 👍🏼
Some of you may be having the same issue I was if following along with this tutorial with the latest version of Cinemachine. The combat camera wasn't keeping the position of the freelook camera and vice versa so if I did a 180 with one camera and then switched it would move back to the other side of the player. To fix this there's a checkbox in the "Transitions" section of the CM camera called "Inherit Position". Turn that on for all cameras involved and they should follow fine.
Thank you soooo much for the information :)
thanks so much. but do you know how i can make it transition faster?
@@Sooshoo_sans You can just go to the default blend in the CinmachineBrain and just lower the S value
DOOD!! God Bless You, You are AWESOME!!!!
Man you saved may day,thank you!!!!
Thank you so much for this tutorial series! Very much appreciated. Can't wait to see what else you decide to add
this tutorial can be a kickstarter to many glorious opportunities for game devs! ur soo underrated!
Thank you so much!
Thank you so much for this tutorial! I've looked at a million, but never could figure out the " combat " type camera where in the character is always facing forward. Thank you thank you thank you!!!
This tutorial is pretty much exactly what I was looking for, it's honestly so undera- ohhh you released this yesterday LOL
Haha thanks, glad I could help!
I can’t express how much i love you right now!! Thanks you so much! I’m working on a Multiplayer game and this will be essential to me
So glad to hear that! Best of luck with your game
@@davegamedevelopment Thank you man! You deserve the best for real
Dave you're the sole reason as to why I'm sticking with game development; these tutorials are so helpful, can you make a video on a dash system?
Thank you so much, really means a lot to me! And I'm currently working on a Dashing Tutorial :D
Absolutely love the tutorial. It has helped me learn about cinemachine cameras so much!!
Great video! Was frustrating to figure out the issues I had with my project, but it worked out perfect in the end.
Such an Insightful tutorial. You made it so easy to understand. Thank you for the help
Okay wow this is literally the most helpful tutorial I've ever watched. Thank you so much! :D
Glad I could help! Thanks for watching :D
Thnakyou, these tutorials are so helpful, kindof inspires me to make a parkour game when i gather enough knowledge. Love you shisho
thank you so much for this! i usually struggle a lot with video tutorials, but this was so clear and helpful i managed to get one step closer to making my dream game!
How did you even understand he kept changing his hierarchy structure without even saying anything?
your tutorials are absolutely amazing!! thank you so much
Bro you are much better than those with millions of subscriber out there i have learned a lot from you..
You are seriously underrated, loving the easy to understand content
Thanks a lot!
I finally found a tutorial that gets to the point. Thank you.
love the capsule effect! so hip and funny lol
Your tutorials are so helpful! Thanks. :)
Glad you like them!
This channel is a gold mine.
This tutorial helped me, thanks.
I noticed that the character would start to follow an "arc" and gradually drift from their original starting position when continually moving side to side with A and D as well as when strafing in other directions. For anyone else who needs help fixing this:
Under your Cinemachine Freelook camera, go to Orbits and expand the Body tab for Top Rig and set X, and Z damping to 0. Repeat this for the Middle and Bottom rigs. Now the camera will follow the character perfectly without rotating itself to track them as they move to the sides, which also keeps your movement inputs and camera angle perfectly consistent instead of gradually drifting.
tysm for figuring that out!
I'm have watch your video really easy to understand. Thanks for the explanation 🥰😻
Thanks, glad you like them! :D
You're amazing dude, thanks a lot!
you deserve more views man nice content
that's what i want for a long time! thanks for sharing!
Glad I could help!
the tutorial worked just fine, thanks
Never forget the most important step in a coding tutorial, .75x speed
I love you man, thank you. I hope you keep it up. Not to raise comparisons but you're among the best tutorial makers we have right now
Thank you so much, glad I could help!
This stuff is real good! Well explained, easy to understand, and to the point! Though i was having some issues with the quality of the movement script. When you press left and then right the player rotates immedietly which is all fine for most games but for games where you wanna focus on a more realistic approach i find that using Linear interpolation much more optimal.
// rotate the player
float horizontalInput = Input.GetAxisRaw("Horizontal");
float verticalInput = Input.GetAxisRaw("Vertical");
Vector3 inputDir = orientation.forward * verticalInput + orientation.right * horizontalInput;
if (inputDir != Vector3.zero)
{
Quaternion toRotation = Quaternion.LookRotation(inputDir, Vector3.up);
playerSkin.rotation = Quaternion.Lerp(playerSkin.rotation, toRotation, Time.deltaTime * rotationSpeed);
}
That's so cool!!! Thanks 👍
Glad you like it!
thanks for this nice and easy tutorial
Thank you!!
Outstanding!
This is awesome thanks.
Glad you like it!
I just did this myself. Took me two days, whish i knew this was coming.
Haha that's though, but doing something yourself is also very important when learning how to code :D
this is awesome :)
Thanks a lot!
Hey! I have been following this series, and it's awesome! But, could you do a tutorial on adding footsteps to this system? :)
Thanks a lot man! And yeah I'll think about it :D
Excellent thank you
Glad you like it!
Thank you very much :D
You don't have to deactivate the cameras. You can blend between Cinemachine cameras by altering the priority value through code. Deactivating the cameras can actually mess up the blends in some cases.
Ok thanks for the feedback! I don't use cinemachine that often, was actually quite surprised that it blends even though I'm just deactivating them haha :D
these videos are the best
YAY WE GOT A NEW TUTORIAL IN THE SERIES 😁
LET'S GO! :D
@@davegamedevelopment OMG! WHEN IS SOON FOR THE DOWNLOAD LINK?! O_O CAN YOU UPLOAD IT TO MEGA FOR NOW! I have been TRYING to find a Third Person movement system that works with Cinemachine and allows the player to move in the direction the Cinemachine camera is facing and also rotating the player whilst still being able to move the player. Rotating the player without the player actually MOVING when hitting A / D keys but still rotating.
if anyones having trouble getting the camera set up withthe new cinemachine they moved the menu to the scene create object menu and you need to put the camera component on the cinemachine brain not as a gameobject but a component
this just flew WAY over my head.
but ill try it (-;
Hats off Man
Thanks man!
Great tutorials
Thanks!
This is one of the best character controller tutorials on RUclips. You deserve a lot more attention for this. One question: it there a way to increase the speed that the camera transitions between camera angles? the transition feels a little too slow for a game where you have to transition often and very quickly.
Edit: also, in the first person movement video the gravity seems much higher than mine is. I ended up using a script to manually add a custom gravity force but I was wondering if there was a better way to do it.
Edit again: I also noticed that the two separate cinemachine cameras save their last position before you switched away from them, meaning sometimes when you switch it can completely turn around your camera view and player which is unideal. is there any way to update the position of the cameras when you switch to them to avoid this?
I figured out how to change the blend speed, in the cinemachine brain on the main camera you can change the amount of time the blend takes under default blend.
I figured out a solution to the last question too: alongside each cinemachine game object, save each cinemachine as a cinemachine.cinemachineFreeLook as well. then, in the camera switch function, use if statements to find out what the current style is and than use the cinemachinefreelook variable of that camera to find out what its current x value is. then, set that x value to the camera you are switching to. I probably made that way more complicated than it needs to be but it works so I'm happy.
Thanks a lot man! Also glad that you could fix most of the problems - and thanks for sharing the solutions with others!
As for the gravity, yes there is a better way, go to Project Settings -> Physics -> Gravity and change it to 0, -30, 0
@@JSO18 hey im having the same issue, i understand you solution to a degree, you mind posting that bit of code please. thanks
@@kersensei Me too, a little bit of code will help
thank you so much
Can't wait for the implementing of blender animations and models into unity tutorials! I hope
I have a question about how you setup the GameObject for movement. Why do you use a separate empty child to track the player's orientation instead of just relying on the parent GameObject's Transform?
you helped me so much! Thanks a lot man. However, I am stuck with something I don't know how to fix, which is whenever I try to switch camera, it also change the direction of my character as well. I think it because each cinemachine camera has different x,y,z coordinates when it was activated, and because the cameras don't line up, so the script that make the character moves to where the camera look at is kinda mess it up a little bit. Do you know how to fix this? Thanks a lot again!
For anyone looking to fix the jitter on combat camera, it's because the animation is uneven, this happens because some of the code he used was used in Update() instead of FixedUpdate() in the Movement script. To fix it move SpeedControl() and the ground drag block of code into FixedUpdate() and the jitter should be gone.
I tried this but didn't work sadly, everything is still jittery, i even moved everything in the camera script to fixed update instead of update
@@zeyadelgendi1288 late response, but if you still have this issue, i found that messing with the "Update Method" on your CinemachineBrain component, and removing dampening on your cameras can fix it. i spent ages messing with settings back and forth but i hope it helps ^^
ngl sometimes this guys sounds like Brackeys, nice vid btw.
An issue I'm havinng is that the capsule will start to lean down toward the ground when looking down and that is causing issues with movement like I can't move as the character is trying to move down into the floor
Hey dave i have a simple problem when regarding the cmobat look at style. when I look around the player does not rotate towards where the camera is looking i have checked the code multiple times and it is the same as yours
same
I keep getting Look rortation viewing vector is zero in console and can't turn the player model without using the walking commands and even then it doesn't walk properly it would just keep walking off in one direction.
Amazing video bro! keep up the hard work! I got an issue, so when I press the alpha key 2 which is combat mode, it changes the camera but not the mode, but if I press it again it changes the mode! so how do i get it so that when i press it once it changes the camera and mode?
Great tutorial, but I'm having issues where the player movement is set to two axis so if I flip the camera the w key input will move me towards the camera, any fixes for this?
Thank you so much for this. But quick question, how do I setup the animations for the PlayerObj model? I'm currently trying to use an animator controller with a blend tree for animations.
Okay so for anyone else wondering/struggling on this: This may not be the best solution, but it works:
1.) Make PlayerObj no longer a child/make it its own object, add the rigid body component like the player object, add the script (same values as the player object), apply the animator controller to PlayerObj, deactivate the script on the player object, and make the Orientation object a child of the PlayerObj.
2.) In the ThirdPersonCam script, replace: "Vector3 viewDir = player.position - new Vector3(transform.position.x, player.position.y, transform.position.z);" with "Vector3 viewDir = DiddyKong.position - new Vector3(transform.position.x, DiddyKong.position.y, transform.position.z);" Then change the Update() function to FixedUpdate()
3.) In the references for PlayerCam, put PlayerObj's rigid body for Rb
4.) On the ThirdPersonCam/Cinemachine free look camera, change "Follow" and "Look at" to PlayerObj
This is what I did and now I can have my animations on my PlayerObj since I need to do it in the movement script, but that was only attached to the parent object (Player), which caused issues.
Please more tutorials about the skills of walking on ropes, and like so of the minute flats, movement near the walls and hanging like the Assassin's Creed method, A surprise attack on the enemy thank you.
Thanks for the suggestions, I'll think about it!
For some reason in the Top camera, the capsule seems to be pushed (tilted forwards or backwards) even though the rotations are fixed. Do you know why this is happening?
I really like the shader of your capsule. Can you make a tutorial?
Great video! Could you make a tutorial on how to pick up items in third person please?
How can I attach an animation to an object and have it move in the specified direction?
As shown in your video where the little man jumps every time he walks
When I try this, the camera jitters when I move directly left or right. Anybody have any ideas why this might be the case?
Hello, i have a little problem
when i look down a little bit the camera shoes a blue bg and two red lines on vertical and one horizontal and i think it shows my cam movement, can you help me fix this pls
Hey, quick question, how do we use our own avatar instead of the capsule? because when i add the same settings n stuff to my avatar and dissable the capsule, it doesnt work properly with my own avatar
Got a problem. When I'm in the combat mode the player doesn't stay fixed on the screen, they drift off to the sides. I ended up copying and pasting your code over the script (and removed the top-down section as I don't want that in there), but that still didn't fix it. I'm using 2022.3.16 so I'm not sure if something has changed or not. The basic view works fine too.
Also, how would you go changing between multiple targets, like hitting 2 again and have it go to the next closest or in sequence?
Dear Dave, I Love your Turtoial Videos But There is a problem I'm facing I'm tryna make a demo game but I'm facing a lot of issues, i wonder if you could remake your scripts or like Clean up the project files, because I'm a beginner and I'm looking forward to learn more, But Great Work ❤️
Thank you so much now im starting making money
Hey!
So I am trying to implemet moving platforms (without using rigifbody) but cant seem to make it work properly with the controller, I tried making the player child of moving platform but it makes moving the character on platforms gittery. Is there any way I could fix this?
It's important to note to turn off gravity on the player object if you don't have a floor, or else it will just fall to oblivion. found that out the fun way
How could you add a player model and animations to this? Could you create a video on this? Please and thank you.
Legend fr
Player wont change what "forward" is for them despite camera moving. How would I do about fixing this?
God Bless You, THANK YOU SO MUCH!! Is it too late to perhaps request a rope-walking mechanic? Please?
I have a question: where do you add animate codes in your movement script?
I would make a separate script called somthing like "PlayerAnimationHandler" for that :D But to start out you can of course just use void Update or play animations from the state machine.
While helpful, I want to say it is a bit irritating when I unknowingly click on this video with the goal being to learn how to SCRIPT MY OWN 3rd person camera. If I want to learn how to make a 3rd person camera/movement, and then just be told "just download and implement this pre-made package lol", it's a bit grinding.
But other than that, this video was very well made and did help me out what I need to think about, so You still earned my Like.
I have a problem. I'm making a 3D action game. Each time I use transform.rotation and slerp to turn the playerObj to rotate towards a lockedon target to attack them, afterwards, it looks like my character is swimming in the ground briefly when I turn away from the target to run away. It's not a breaking proble, but I think it's a problem, because that means my playerObj's rotation is moving unnaturally in the X-axis. And this is after using rigidbody and rotation constraints
Going Thru this tutorial but I don't see how the CameraHolder was set up can you explain this ?
There is one more issue. How to make the camera line up behind the player when he is goes "toward us", because we always see his face and not what is in front of him.
Hi the code works very well and thanks for the tutorial but i have a porblem i add my character so when i move forward the character rotate backward and when i move backwards my character rotate forward can you help me and again thanks for this tutorial
hi, i'm running into a problem.. when i go to test the camera movement/player turning (the first code tutorial here), my player character just falls to the side and spins around there, as well as not moving when i move the camera. it happens when i pres WASD or the arrow keys. i have my player object named 'playerbody' instead, but i don't know if that would change anything. i'm also not sure where the code itself goes, as i have the player camera and the CM freelook. sorry for the long comment, but if anyone has any help that'd be awesome!
I believe the issue comes from you putting your script on the wrong object. My guess you added it to the player, instead try putting it on the main camera!
hey guys, i was wondering. How could i change the capsule to maybe a real character? I already have the character rigged up, i just dont know how to apply it. When i replace the capsule, the character doesnt face the direction hes turning at.
4:46 you said that player and player obj is all you need the a whoole lot of other stuff is added i dont get it which one did you pput the script in and how are we supposed to know what the names are and what they do
Amazing. Love ur content. Could you show us how to make subway surfers stylish endless runner game tutorial.
Thanks a lot! And I'll think about your suggestion! :D
hey Dave your tutorial really helped but I'm currently facing problem with jump. grounded is not working
I always had a problem with cinemachine because everytime i try and import it to my project it create a doc in my project panel and nothing on top of my screen like you. i download it and import it but it still dont work. Can somebody help me pls?
hummmmm, there's a problem in mine, after I installed there was no option saying "Cinemachine" in the top options, what do I do?
sorry i have a problem: when i put the player in follow and look at and i start the game it say no cameras rendering, why?
1:48 Please help, i did everything what you did but when clicking play the camera was automaticly zooming out. What i need to do?
hey i was wondering what you used to open the c# script in to edit it
Why when I have gravity checked on the rigidibody enabled does my camera start floating up into space?