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
  • Навчання та стиль

КОМЕНТАРІ • 118

  • @GameDevExperiments
    @GameDevExperiments  Рік тому +10

    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

  • @MahmoodAlSaghiri
    @MahmoodAlSaghiri 10 місяців тому +16

    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.

    • @GameDevExperiments
      @GameDevExperiments  10 місяців тому +4

      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.

  • @yuxue2801
    @yuxue2801 11 місяців тому +2

    Thank you. I love this kind of build from scratch tutorial. Sometimes the packages are hard to understand without these knowledge.

  • @vidhusansurenthiran5730
    @vidhusansurenthiran5730 Рік тому +5

    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.

  • @OlleReberg
    @OlleReberg 11 місяців тому +1

    Really amazing tutorial! Thorough in both showing how to and explaining why you're doing it x way and how it works. Thank you!

  • @avinashsingh3094
    @avinashsingh3094 4 місяці тому +4

    Thank you so much man ❤❤❤ this gonna help me in my major project ❤❤❤

  • @jameskemeny9886
    @jameskemeny9886 Рік тому +2

    Easiest sub of my life mate, what an excellent tutorial!

  • @joeldowdy564
    @joeldowdy564 Рік тому +2

    Amazing tutorial. Thank you so much for the detailed explanations. So much better than just telling us what we need to do!

  • @hypercharge26
    @hypercharge26 Рік тому +2

    Appreciate your work on this

  • @darrellwillis4871
    @darrellwillis4871 Рік тому +6

    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.

    • @GameDevExperiments
      @GameDevExperiments  Рік тому +2

      Thanks a lot for the feedback Darrell. I'm thrilled to know the teaching style is working.

  • @roydonk2878
    @roydonk2878 Рік тому +4

    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.

  • @lavishsingal4791
    @lavishsingal4791 Рік тому +2

    amazing work bro you nailed it

  • @afnanali6274
    @afnanali6274 4 місяці тому +3

    NullReferenceException: Object reference not set to an instance of an object
    PlayerController.Awake () (at Assets/Scripts/PlayerController.cs:11) error, pls help

  • @BetterStudiosOfficialChannel
    @BetterStudiosOfficialChannel Рік тому +2

    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.

  • @reikomvs
    @reikomvs 9 місяців тому +1

    bro u are amazing, please make more tutorials like this

  • @ChadEricCartman
    @ChadEricCartman 11 місяців тому +2

    bro this guy is damn good at explaining stuff man. One of a kind tutorial.
    Super underrated Channel. Thank you Athul.

  • @Ruti3131
    @Ruti3131 4 місяці тому

    thank you for you insights and yeachings they are really helpfull

  • @spangeman3994
    @spangeman3994 Місяць тому

    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.

  • @utpakhi4627
    @utpakhi4627 10 місяців тому +1

    Holy Moly , Nice Tutorial , You are insane . Take Love

  • @dushandilshika7389
    @dushandilshika7389 Рік тому

    Thank you so much for the tutorial. Subscribed..

  • @jinitdave
    @jinitdave Рік тому

    Good video, a big thumbsup, I have a question why is my character's gravity sudden?

  • @indomienak1668
    @indomienak1668 Місяць тому

    please make some video tutorials like this. it is very helpful ❤

  • @vivanecrosis
    @vivanecrosis Рік тому +1

    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!

  • @peterpanaki6591
    @peterpanaki6591 10 місяців тому

    Thank a lot for perfect video I hope you create a lot of tutorial like this and I already bought your course

    • @peterpanaki6591
      @peterpanaki6591 10 місяців тому

      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?

  • @Nick-gb3rq
    @Nick-gb3rq 7 місяців тому +1

    what if I want to add a cinemachine component to the camera to make sure that it doesn't phase through objects

  • @MsWital
    @MsWital 2 місяці тому

    Отличный урок, большое спасибо!

  • @mattkirby115
    @mattkirby115 10 місяців тому +1

    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.

  • @videonoisetv65
    @videonoisetv65 4 місяці тому

    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?

  • @richiezafra9061
    @richiezafra9061 Рік тому

    Hey, for some reason it's not allowing me to put my camera on a target, do you know what may cause this?

  • @HyperionWarlord
    @HyperionWarlord 3 місяці тому

    your're the goat man

  • @vetirs
    @vetirs 4 місяці тому

    Only for me the character continue to move for a bit after I release the move key?

  • @aiyenurooluwaseun2280
    @aiyenurooluwaseun2280 6 місяців тому

    Sooooooo great.

  • @zafrafam
    @zafrafam Рік тому +1

    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

  • @frandomplayz5438
    @frandomplayz5438 Місяць тому

    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.

  • @hakimsabkhi3944
    @hakimsabkhi3944 4 місяці тому +2

    Could you explain how to control the camera in a 3D environment by clicking and dragging the mouse?

    • @thestorminmormin1442
      @thestorminmormin1442 16 днів тому

      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.

  • @talismanskulls2857
    @talismanskulls2857 Рік тому +1

    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.

  • @bradenmusic311
    @bradenmusic311 5 місяців тому +1

    Bro your a natural teacher, everything makes sense now! Tried so many tutorials before this. Thanks man, keep up the good work

  • @HyperionWarlord
    @HyperionWarlord 3 місяці тому

    the joystick implementation makes my camera rotate on the x (4th axis) continuously, HELP!

  • @dushandilshika7389
    @dushandilshika7389 Рік тому

    Best tutorial. Thank you.

  • @zachariahtaylor5162
    @zachariahtaylor5162 Рік тому +2

    I needed this!

  • @junaid7040
    @junaid7040 11 місяців тому +2

    I do all correctly but the console showing Null reference Exception: Object reference not set to an instance of an object.
    playerMovement.Update()

    • @Killertrifle
      @Killertrifle 11 місяців тому +1

      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

    • @junaid7040
      @junaid7040 11 місяців тому

      Can you please send me the player controller script

  • @JarppaGuru
    @JarppaGuru 10 місяців тому

    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

  • @ZYR_WAX
    @ZYR_WAX 10 місяців тому +2

    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?

    • @rubatron6152
      @rubatron6152 9 місяців тому

      look if public class "name" and script "name" match

  • @erfanzandi1362
    @erfanzandi1362 11 місяців тому +1

    Great video indeed man, thank you.

  • @ktvx.94
    @ktvx.94 8 місяців тому +1

    Awesome tutorial man!

  • @Properpeanut
    @Properpeanut 4 місяці тому

    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.

  • @Ylyisbot
    @Ylyisbot 9 місяців тому +2

    You help me a lot, thanks to your videos, I can learn English and unity c#)

  • @AhmadRaza-ph9dv
    @AhmadRaza-ph9dv Рік тому +1

    how to add jump using this blend trees?
    Please Help me
    Waiting for your response

    • @GameDevExperiments
      @GameDevExperiments  11 місяців тому

      You have to add it as a different state outside the blend tree and transition to it based on a condition

  • @harshkanaskar2166
    @harshkanaskar2166 8 місяців тому +1

    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

    • @softart5235
      @softart5235 7 місяців тому

      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.

  • @Black_Jay_LBS
    @Black_Jay_LBS 10 місяців тому +1

    Thank you so much sir, This was soo helpful😍🤩🤗

  • @X-Lici
    @X-Lici 8 місяців тому +1

    one word: PERFECT!!

  • @cevan2647
    @cevan2647 Рік тому +1

    1:04:00
    I am experiencing an error where "loop match" in "Root Transform Position (XZ)" appears in red.

    • @GameDevExperiments
      @GameDevExperiments  Рік тому +2

      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.

    • @vivanecrosis
      @vivanecrosis Рік тому

      @@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.

  • @Ruti3131
    @Ruti3131 4 місяці тому +1

    hi i have a problem my camera is not keeping up with my playersmovement , how can i fix that

    • @Properpeanut
      @Properpeanut 4 місяці тому +1

      use LateUpdate() instead of Update() in your cameracontroller

    • @Ruti3131
      @Ruti3131 3 місяці тому

      Oke thaank you imma try it

  • @dusty8446
    @dusty8446 8 місяців тому +1

    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

    • @GameDevExperiments
      @GameDevExperiments  7 місяців тому

      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.

  • @tedc1928
    @tedc1928 Рік тому

    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.

    • @LGTGHOSTHUNTING
      @LGTGHOSTHUNTING 4 місяці тому

      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.

  • @AhmadRaza-ph9dv
    @AhmadRaza-ph9dv Рік тому +1

    Amazing Video,,, it is best video over 10000000000000 videos....Love you Boss

  • @dmlrblx-dragonmanialegends6536

    Will jumping be covered in the course?

    • @GameDevExperiments
      @GameDevExperiments  Рік тому

      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?

    • @dmlrblx-dragonmanialegends6536
      @dmlrblx-dragonmanialegends6536 Рік тому

      @@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 😉)

    • @GameDevExperiments
      @GameDevExperiments  Рік тому

      @@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.

  • @Rahulsingh-theraha
    @Rahulsingh-theraha Рік тому

    are you done with this course?[means is it completed]

    • @GameDevExperiments
      @GameDevExperiments  Рік тому

      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?

    • @Rahulsingh-theraha
      @Rahulsingh-theraha Рік тому +1

      @@GameDevExperiments thanks a lot for confirmation

  • @goatvalencia6573
    @goatvalencia6573 Рік тому

    how can we setup input system

    • @GameDevExperiments
      @GameDevExperiments  Рік тому +1

      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.

  • @johnboycetiongson3104
    @johnboycetiongson3104 27 днів тому

    Im having so much trouble with isGrounded I always get Error

  • @atg5021
    @atg5021 Рік тому +3

    Heyooo, was waiting for this!!! Not to ruin the mood, but RIP technoblade.

  • @anway9797
    @anway9797 24 дні тому

    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

    • @GameDevExperiments
      @GameDevExperiments  24 дні тому +1

      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.

  • @JarppaGuru
    @JarppaGuru 10 місяців тому

    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

  • @factopedia....
    @factopedia.... Рік тому

    07:11

  • @abdalrahmanahmad9146
    @abdalrahmanahmad9146 Рік тому +1

    Please make module about fighting like assassin's creed

  • @t.g.zcomedy2623
    @t.g.zcomedy2623 Рік тому

    Cant we just use cinemachine

    • @GameDevExperiments
      @GameDevExperiments  11 місяців тому +1

      Yes, you could use Cinemachine. I made the camera controller from scratch because it's good to understand how it works.