Create a Third Person Controller in Unity from scratch
Вставка
- Опубліковано 4 чер 2024
- Checkout the full Third Person Parkour System Course here - fantaco.de/unity-parkour-system
Hey everyone, in this video we'll create a Third Person Controller in Unity. We won't be using any assets to build it, we'll build it completely from scratch because it's a good way to learn the fundamentals of 3D game programming,
and it will give you the knowledge to customize the controller for your own games.
So while building the controller, you'll learn important concepts like
- unity's character controller component
- camera relative movement,
- humanoid retargeting for reusing animations on multiple characters,
- using physics for ground detection, etc.
0:00 - Introduction & Demo
1:03 - Project Setup
4:30 - Camera Controller
27:24 - Character Movement
48:04 - Setup Animations
1:04:59 - Animating the character
1:20:25 - Collisions & Gravity
1:45:28 - Controller Input
1:51:03 - What next?
If you want to build upon this and and create a more advanced controller that can perform parkour actions then checkout our Unity Third Person Parkour System course here
fantaco.de/unity-parkour-system
Checkout the Third Person Combat System Course - fantaco.de/unity-combat-system - Навчання та стиль
Checkout the full Third Person Parkour System Course - fantaco.de/unity-parkour-system
Checkout the Third Person Combat System Course - fantaco.de/unity-combat-system
Ive watched countless videos about third person camera controllers. Half of them just used cinemachine and i wanted to learn how to do it from scratch, and the other half made it overly complicated or simply didn't know how to explain. You showed a concept that I finally understood, thank you very much.
Thanks a lot for the feedback. I too struggled with understanding the camera controller while creating my first third-person controller. So I thought I'll create that from scratch for this course.
Thank you. I love this kind of build from scratch tutorial. Sometimes the packages are hard to understand without these knowledge.
Thanks, I'm glad you like it :)
finally a video that explains so well and not rush like other tutorials. the way you explain it is really good bro. You should be a teacher.
Thanks a lot for the feedback :)
Really amazing tutorial! Thorough in both showing how to and explaining why you're doing it x way and how it works. Thank you!
Thanks a lot for the feedback :)
Thank you so much man ❤❤❤ this gonna help me in my major project ❤❤❤
Glad to hear that :)
Easiest sub of my life mate, what an excellent tutorial!
Thanks a lot mate :)
Amazing tutorial. Thank you so much for the detailed explanations. So much better than just telling us what we need to do!
Thanks a lot for the feedback :)
Appreciate your work on this
Thank a lot for the feedback :)
Absolutely amazing; I like how you explained like
"We want the camera to go around the character"
*Adds a line of code for that*
"Ah, but see here's the problem... It now is doing the one thing we wanted, but we have a slightly different problem".
Like progressively solving problem until you have the code do EXACTLY WHAT YOU WANT. Which helped me definitely understand some of the ideas and even syntax of what you were writing.
Thanks a lot for the feedback Darrell. I'm thrilled to know the teaching style is working.
You are a great teacher. I went through all your Pokemon in Unity videos and now I'm diving into 3D game dev. Thanks for all of your awesome content.
Thanks for the feedback. I'm glad to hear it's helping!
amazing work bro you nailed it
Thanks bro :)
NullReferenceException: Object reference not set to an instance of an object
PlayerController.Awake () (at Assets/Scripts/PlayerController.cs:11) error, pls help
You definitely earned my sub, bro was so good at explaining everything that I couldn't understand and it worked perfectly. I also loved how he showed slowly how to fix a problem that a professional would most likely do without thinking straight.
Thanks a lot for the feedback. You made my day.
@@GameDevExperiments np you made mine
bro u are amazing, please make more tutorials like this
bro this guy is damn good at explaining stuff man. One of a kind tutorial.
Super underrated Channel. Thank you Athul.
Thanks a lot Eric. You made my day :)
thank you for you insights and yeachings they are really helpfull
This video may be longer than others on the same subject but I highly recommend sticking with it. The whole video is very useful and you will learn a lot. I've tried other videos on third person controllers and they don't come close to this. By the end you will have a complete understanding of what you've got setup so you can take it in whatever direction you need for your game.
Holy Moly , Nice Tutorial , You are insane . Take Love
Glad you think so :)
Thank you so much for the tutorial. Subscribed..
Good video, a big thumbsup, I have a question why is my character's gravity sudden?
please make some video tutorials like this. it is very helpful ❤
Absolutey SUPERB! This tutorial worked so well it's unreal! I only had to make some minor changes, as my models are not from mixamo.
It's such an amazing feeling to have a character I designed running about.
Even more important is the fact that I learnt so much!
Thanks a lot for the feedback. So happy to hear it helped.
Thank a lot for perfect video I hope you create a lot of tutorial like this and I already bought your course
May I ask why you use charactercontroller instead of rigidbody you said that it will cause a lot of problem with external force what kind of problem? Is charactercontroller better than rigidbody?
what if I want to add a cinemachine component to the camera to make sure that it doesn't phase through objects
Отличный урок, большое спасибо!
How would I change the code so that my character stops as soon as I let go of the movement button(wasd)? currently there's a small delay between when I let go of the button and when my character stops moving.
Followed the tutorial and the movement works great! I’m still trying to figure out how to implement jumping into the script, has anyone had any luck with this?
Hey, for some reason it's not allowing me to put my camera on a target, do you know what may cause this?
your're the goat man
Only for me the character continue to move for a bit after I release the move key?
Sooooooo great.
For some reason when adding my character and playing after creating my movement script, the camera is offset on the right of the character even though I have it as 0, do you know a fix to this?
*Edit: Managed to set it to -2 and it's now even it also doesn't stick on the player and instead has a weird directional when I move my mouse, this is a little odd but I guess it works, let me know if you know a fix to this
Hey, I just faced a problem, I cant Extract Textures of the charcter it does not work it is blured out, Please kindly help me.
Could you explain how to control the camera in a 3D environment by clicking and dragging the mouse?
Maybe create an if statement: If (Mouse Clicked): do Input.GetAxis("Axis"). So it will only take mouse input if the mouse button is also down.
When I applied the following, all the parts with Quaternion marked as errors because while coding this you may get an automatic addition of Numerics abover using UnityEngione; and will need to remove it for those that run into that issue. As to my issue with this there are two main ones. Also the movement for the camera for the -45, 45 is not responding at all.
When i hit play, I get an error that "not set to instance of an object and its marked as under line
var moveDir = cameraController.transform.rotation * moveInput; Obviously it is but its not seeing that in the editor.
I was trying to add a right click/hold down Right Mouse so I dont have to constantly hit the escape key and I dont want the player snapping back to face backwards. I want to simply be able to move backwards without the that but still want to be able to turn right or left. If i move backwards I want the player to simply move backwards.
Bro your a natural teacher, everything makes sense now! Tried so many tutorials before this. Thanks man, keep up the good work
Thanks, I'm so happy to hear that :)
the joystick implementation makes my camera rotate on the x (4th axis) continuously, HELP!
Best tutorial. Thank you.
I needed this!
I'm glad to hear that :)
I do all correctly but the console showing Null reference Exception: Object reference not set to an instance of an object.
playerMovement.Update()
getting the same thing, this error normally means that its trying to access something that doesnt exist but im checking over the code and cannot for the life of me figure it out
Can you please send me the player controller script
so what diff that take sample controller and look code change it. do samething from crash and call it yours. make video bout it sell it with course
i have this error Assets\Scripts\PlayerController.cs(9,5): error CS0246: The type or namespace name 'CameraController' could not be found (are you missing a using directive or an assembly reference?)
how do i fix it plz?
look if public class "name" and script "name" match
Great video indeed man, thank you.
Thanks for the feedback :)
Awesome tutorial man!
Thanks, I'm glad you think so :)
Subbed and liked. Very well explained tutorial.
Nice to see a tutorial that does not just import cinemachine and the third person controller from the starter assets. This is awesome. I have one question though. Wouldn't it be better to have all the camera movement in LateUpdate() to avoid jitter or stutter?
I guess it depends on whether you are going to move the character with physics or not later on.
Also, is anyone else getting a delay before the character stops after you stopped pressing any keys? My character moves for a second after I release the key and I thought it was because of the Time.deltaTime, but we only add to the movedirection when the moveamount is greater than 0, so I do not think this is the problem.
EDIT: Using GetAxisRaw instead of GetAxis when getting the vertical and horizontal input, seems to fix it. Apparently GexAxis has some smoothing.
You help me a lot, thanks to your videos, I can learn English and unity c#)
Glad you found it helpful :)
how to add jump using this blend trees?
Please Help me
Waiting for your response
You have to add it as a different state outside the blend tree and transition to it based on a condition
I love this video, you explained it so well, i had just one concern that there wasn't jump functionality. It would be great if it had jump mechanism, other than that lovely content
i agree ,Ive just bought it and have reached your point(Parkour & Climbing System) ,yes there seems to be an issue(stuck for a while ) ,Im starting again Although im using custom character.
Thank you so much sir, This was soo helpful😍🤩🤗
Glad you found it helpful :)
one word: PERFECT!!
Thank you :)
1:04:00
I am experiencing an error where "loop match" in "Root Transform Position (XZ)" appears in red.
It happens if the animation has root motion in it. You have to get an animation without root motion for the loop match to be green. If you're downloading the animations from mixamo, make sure to check the "In Place" checkbox.
@@GameDevExperiments Goodo to know. I always set the Mixamo to In Place, but in case I forget to do it, this helps me know what the error migh the, thanks.
hi i have a problem my camera is not keeping up with my playersmovement , how can i fix that
use LateUpdate() instead of Update() in your cameracontroller
Oke thaank you imma try it
Thanks for not using cinemachine in this tutorial, since it means that you actually learn the logic of the camera movement, and so it can very easily be translated to tools other then unity
I'm glad you like it. I didn't use cinemachine because I believe it's important to understand how the third-person camera works.
I followed this tutorial and my collision aren't working. I wanted to add an box collider with is Trigger checked to an object and it's detecting it. I can get OnControllerColliderHit to work on the player controller but OnTriggerEnter doesn't work on player controller or objects.
OnTriggers won't work unless one of the objects has a Rigidbody attached to it. Since this is using a CharacterController there is no RigidBody.
Amazing Video,,, it is best video over 10000000000000 videos....Love you Boss
Thanks for the feedback :)
Will jumping be covered in the course?
You mean here or in the parkour system course? In the course, jumping is covered. It's similar to system in games like assasin's creed where the character will only jump when there is an obstacle in front of him?
@@GameDevExperiments Oh, I meant jumping with input from the Spacebar or something. Since, "input jumping" isn't covered in the course will you cover it here,? I attempted it and it was a horror montage😄 Also, I did want to ask if you knew that this was Jeremiah Denning? I just wanted to clarify that I just changed my profile around.
~DMLRBLX (Jeremiah 😉)
@@dmlrblx-dragonmanialegends6536 Hey Jeremiah, No plans to cover that yet. In the future, if I make a game that requires normal jumps, then I'll cover it.
are you done with this course?[means is it completed]
Are you referring to the Udemy course or this video? I'm working on a new module in the Udemy course that covers an Assassin Creed style climbing system?
@@GameDevExperiments thanks a lot for confirmation
how can we setup input system
It should be pretty straight forward if you're familiar with the new input system. You can also refer the implementation of unity's standard asset third person controller to see how they used the new input system.
Im having so much trouble with isGrounded I always get Error
I cant follow up with the Gizmos
Heyooo, was waiting for this!!! Not to ruin the mood, but RIP technoblade.
RIP
Hi, why not use FixedUpdate instead of deltaTime? We can just run all the logic in FixedUpdate and then we won't need a delta... And I also heard that moving a character using Transform is a bad idea, since then (as was seen in the video) the character can pass through walls, probably in the case of an ordinary character (I would say a realistic character) it would be better to use RigidBody instead of the usual Transform. But in general, the lesson is very useful, thanks
If you watch till the end of the video, I'm changing the movement to use character controller instead of directly moving the transform. I didn't want introduce the character controller at the begining of the video iself.
6:18 copy/paste code and explain it if must. it will be 99% same what 99% allready know. what change is your variable names xD
07:11
Please make module about fighting like assassin's creed
I'll probably create a new course for that.
Cant we just use cinemachine
Yes, you could use Cinemachine. I made the camera controller from scratch because it's good to understand how it works.