How to Program in Unity: Third Person Movement Explained

Learn how to set up a third person camera and program our characters to move in the right direction!
This tutorial explains how we can use Unity's Free Look Camera and our own code so that our character movement is relative to the direction of the camera. By the end of the video we'll have a working third person character!
This is also the latest entry in a series of tutorials surrounding Unity's Built In Character Controller, however the script was written and video edited so that anyone can watch it and come away with the same results!
ACCESS PROJECT FILES & SUPPORT THE CHANNEL:
💛 / iheartgamedev
iHeartGameDev Merch:
💛 www.iheartgamedev.com
Like the vid? Please consider Subscribing!
💛 bit.ly/2YdIb6j
Links from Video?
Interested in learning more about the Vector math?
• Camera-Relative Moveme... ✅
Interested in learning more about Cinemachine?
• Cinemachine ✅
SOCIAL:
✦ Discord
/ discord
✦ Twitter
/ iheartgamedev
Jammo is from Mix and Jam:
🤖 Download Jammo for YOUR game:
assetstore.unity.com/packages...
⭐ And Check Out MixAndJam!
/ mixandjam
►TIMESTAMPS:
Introduction - 0:00
Getting Started with Cinemachine - 0:30
Third Person Cam Initial Set Up - 1:40
Let's get Progamming: 2:56
How the example character currently moves: 3:39
Basic example movement: 3:59
Current problem and solution visual: 4:10
Programming ConvertToCameraSpace solution: 4:31
How to Rotate a Vector: 5:35
Programming ConvertToCameraSpace solution part II: 6:07
Fixing missing Y Movement: 6:46
Fixing character rotation: 7:22
All the important changes for a better feeling camera: 8:28
FOV: 8:40
Rig settings: 9:00
Moving focus point: 9:28
Slowing down sensitivity: 10:07
End result: 10:30
Coming soon: 10:45

Пікірлер: 79

  • @Luizfernando-dm2rf
    @Luizfernando-dm2rf Жыл бұрын

    This is literally better than some paid courses classes. Your channel is amazing and I have to applaud what you're doing here, well fucking done Nicky 👏(sorry if I misspelled it)

  • @iHeartGameDev

    @iHeartGameDev

    Жыл бұрын

    Thank you for your kind words! I hope that it helps 🙌

  • @Brukrex

    @Brukrex

    Жыл бұрын

    Better Some paid courses? Can you link them "better?

  • @gabrielmelo4541

    @gabrielmelo4541

    Жыл бұрын

    @@iHeartGameDev hello what is the name of the visual studio code theme you are using

  • @vicetbeki3734
    @vicetbeki3734Күн бұрын

    your content is amazing , i found what i was looking for there , from boolean animation to blend trees , retargetting , third person movement etc , everything is well explained , and the videos are not too long , respect and thank you

  • @touchlight6751
    @touchlight6751 Жыл бұрын

    As someone who is working on a project finding this channel is the best thing happened to me this year

  • @georgewashington3505

    @georgewashington3505

    10 ай бұрын

    Where the project at though

  • @iHeartGameDev
    @iHeartGameDev Жыл бұрын

    Thank you all for checking out the new tutorial! I'm so excited to finally share a tutorial on how to set up a third person camera and third person movement that feel good to use. It took a minute to get here and I know that a lot of you were waiting for it, so it's awesome that it is finally out! Thank you all for the support! I hope this helps you all on your gamedev journeys and I can't wait to share more 💛 Cheers!🍻 -Nicky

  • @sarkariadmi4058

    @sarkariadmi4058

    2 ай бұрын

    Can you please take it to more advance level . Like combat states, combos, sword draw and out, wall run, climb etc

  • @sarkariadmi4058

    @sarkariadmi4058

    2 ай бұрын

    Please 🙁🙏

  • @pat17681
    @pat17681 Жыл бұрын

    Thanks for this, waiting now

  • @greeng448
    @greeng448 Жыл бұрын

    Finally a third person tutorial. I have followed your animation tutorial and it when so well your code are very easy to understand. I will definitely watch this tutorial when it come out. Love from Vietnam 🇻🇳 .

  • @matthewmathis62
    @matthewmathis62 Жыл бұрын

    Looking forward to it!

  • @lanefaulhaber875
    @lanefaulhaber8759 ай бұрын

    Hey, thank you sooooo much for these videos! These have been super helpful to me as I've been beginning making my first game!

  • @lanefaulhaber875
    @lanefaulhaber8759 ай бұрын

    Do you think you could do a video about making backups for unity and the process of trial and error sometime? It probably wouldn't be as technical as these other videos, but I think it could be very insightful for the creative programming process.

  • @kruth6663
    @kruth6663 Жыл бұрын

    Right when I'm actually trying to do 3rd person movement for the first time, I see this video being posted. Strange. Thank you for making these amazing tutorials.

  • @mezya7299
    @mezya7299 Жыл бұрын

    So informative, thanks a lot!

  • @henrifardeau505
    @henrifardeau505 Жыл бұрын

    Great tutorial, can't wait for the rest! 👏🏻 Small question : how would you modify the controller / camera to create an Orc must die style when moving (like strafe right and left) ?

  • @omarenriqueduranavellaneda2938
    @omarenriqueduranavellaneda29388 ай бұрын

    Que gran trabajo, gracias por estos videos.

  • @tigranavagyan1587
    @tigranavagyan1587 Жыл бұрын

    Thank you Nicky, this is AMAZING explanation!!! 👍

  • @OliverWendelin
    @OliverWendelin Жыл бұрын

    These tutorials are really top notch and among the highest quality here on youtube! After finishing the movement and camera series - are you also planning on tackling more complex systems such as inventory systems, item setup (scriptable objets etc.)? it is really hard to find in-depth videos on this topic!

  • @iHeartGameDev

    @iHeartGameDev

    Жыл бұрын

    That sounds like a lot of fun!

  • @iHeartGameDev

    @iHeartGameDev

    Жыл бұрын

    And thank you for the kind words!

  • @irispecquet7252
    @irispecquet7252 Жыл бұрын

    You are the best!! Thanks a lot. I am a third year student in game developpement and I discovered your channel today. You already help me a lot with my project. Awesome channel, thanks again.

  • @iHeartGameDev

    @iHeartGameDev

    Жыл бұрын

    Thank you Iris! Happy to have you in the discord now and an awesome new member of the community!

  • @ankitk18
    @ankitk18 Жыл бұрын

    thanks so much man

  • @Krwatkins0002
    @Krwatkins000211 ай бұрын

    Thank you for the wealth of knowledge on the subject. Really, this is a gem of a tutorial series. I know there are a lot of recommendations and you're probably already well on your way through your next one but I hope you can show how you'd handle something like sliding. Especially when you have stored momentum from moving, falling and possibly things knocking you around like enemies or explosions. I figured most of sliding out using ProjectOnPlane to get the angle and adjust the falling gravity however when I try and go down a slope at a certain angle the X for _appliedMovement is 0 or -1 because of the slope angle and I jitter at the edge of the slope. Hoping for a solution, it's got me stumped for too long now.

  • @lanefaulhaber875
    @lanefaulhaber8758 ай бұрын

    These tutorials have really helped me! But I think there are some things I don't quite understand since making the state machine. Like, how do I know if I need to make a new root state? Also, how do I make new variables that can be read in the PlayerStateMachine class? Or should all variables be written in the PlayerStateMachine class, and then use getters and setters to access them in the other classes? Thanks!

  • @ericelnomada
    @ericelnomada Жыл бұрын

    please make the rigidbody 3dcharacter controller series

  • @fernandogomez9021
    @fernandogomez9021 Жыл бұрын

    It's just awesome

  • @weckar
    @weckar Жыл бұрын

    I've been moving away from the buil-in CC mostly because it limits you to the capsule-shaped colliders - which in my opinion is often a deal-breaker later in development. Looking forward to see what you do with it!

  • @iHeartGameDev

    @iHeartGameDev

    Жыл бұрын

    Thanks Weckar! I think it makes sense to step away at some point too. Both the capsule shape and inability to rotate the collider can be tough to deal with. I'm not sure when it makes sense to do so though, so I'll probably leave it up to the community

  • @Morphexe

    @Morphexe

    Жыл бұрын

    You should just Kinematic Character Controller, or RIval. They are the best Kinematic Controllers out there.

  • @castlecodersltd

    @castlecodersltd

    Жыл бұрын

    @@iHeartGameDev how about creating a video on this - a hand rolled character controller which overcomes these issues, please?

  • @Kino4

    @Kino4

    Жыл бұрын

    @@iHeartGameDev Give Scivolo CC a try, it's free.

  • @LostSol25
    @LostSol25 Жыл бұрын

    Really cool video! You should do a tutorial on procedural animation

  • @TriteanRares
    @TriteanRares Жыл бұрын

    Great Video! I followed it to implement the same for my prototype but there are some problems. I have very jittery camera movement on the Y axis (so when looking up/down), with both mouse and controller, while using the new input system with the CinemachineInputProvider. The cinemachine brain is set to SmartUpdate/FixedUpdate and my target is a rigidbody controlled using AddForce - Acceleeration in FixedUpdate(). I tried LateUpdate but then everything is jittery. It's been 3 weeks and have not solved it yet. Thoughts?

  • @darkdoom907
    @darkdoom907 Жыл бұрын

    Fun story, I made this yesterday all by myself. (P.s. partial thanks to your videos)

  • @iHeartGameDev

    @iHeartGameDev

    Жыл бұрын

    Dark doom! Awesome to hear from you and great to see that you were able to get it working!!

  • @BigodeIlustrado
    @BigodeIlustrado6 ай бұрын

    Could you do a tutorial on an fps movement or how to reuse your series code for an fps?

  • @atokosto
    @atokosto Жыл бұрын

    Wow 😍

  • @KoenfuPanda
    @KoenfuPanda Жыл бұрын

    Can’t wait for this one 🎉

  • @rajeshreddy240
    @rajeshreddy240 Жыл бұрын

    Currently I want to Implement a crouch system but i dont knnow how to implement. In old input system we use If(Input.GetButtonDown) { Crouch = !Crouch; } and we can use this boolean to use crouch just by using only one button but now i cant find a way to implement like this in new input system.When I tried to implement the current state goes to crouch state only during holding the button but I need to switch to crouch state when I click the button and switch to another state from crouch state when i click the same button.

  • @aksiproduktifperadaban8574
    @aksiproduktifperadaban8574 Жыл бұрын

    all workеd

  • @clarkmeyer7211
    @clarkmeyer7211 Жыл бұрын

    cinemachine is also great because you don't have to create extra cameras. the virtual cameras concept is genius.

  • @ponrajp9296
    @ponrajp9296 Жыл бұрын

    lol working thanks

  • @user-sx1rr3rp7c
    @user-sx1rr3rp7c Жыл бұрын

    Can you give some tips on 3d combat? Nobody has a tutorial online.

  • @anupamkumar4109
    @anupamkumar4109 Жыл бұрын

    Can you do mad max style combat system

  • @kruth6663
    @kruth6663 Жыл бұрын

    Hi. I have a beginner's question. Instead of multiplying the x and z vectors separately, what if I use the camera's transform.forward vector3, clear its y value and normalize it, then multiply it with the input vector3? Would that work as well? If it works would there be any problem doing it this way? Your tutorials are awesome, thanks!

  • @orchard800

    @orchard800

    Жыл бұрын

    I was wondering this too.

  • @BlueAndy_

    @BlueAndy_

    Жыл бұрын

    Why dont you try it yourself, its worth a try

  • @JustSomeGameDev
    @JustSomeGameDev Жыл бұрын

    bro i just made a third person cam with my own frecking code then i see this masterpiece 😭

  • @iHeartGameDev

    @iHeartGameDev

    Жыл бұрын

    You probably learned a lot! I hope that this is still helpful!

  • @FioreFire
    @FioreFire Жыл бұрын

    the camera space conversion could be reduced down to just a couple lines of code with TransformDirection()

  • @tomdriver6733
    @tomdriver673311 ай бұрын

    My Character is moving in a Circle around the Camera, when strafing to the left or right. What could be the Problem? I want it to move in a straight Line.

  • @ethanharris8713
    @ethanharris87134 ай бұрын

    I have no idea what's wrong with my character, but the model will only rotate with the camera sometimes and never past 90 degrees... Anyone know what's up?

  • @Yamartim
    @Yamartim Жыл бұрын

    Hey guys i've had an issue where the camera relative movement works perfectly in the editor but after building the game it becomes fixed again, did anyone else have this issue? I found nothing on it on the internet and spent the whole day on it with no clue what to do...

  • @ultragamerpro6903
    @ultragamerpro6903 Жыл бұрын

    I know this is a tall order, but could you please make a version of your tutorial series for unreal engine? I have been looking everywhere for resources on creating Mario Odyssey style movement! If you don't have the time to dedicate to this task, could you at least point me towards resources to help me implement Odyssey style movement in unreal engine?

  • @matthewmathis62

    @matthewmathis62

    Жыл бұрын

    What you're talking about is called a *3D Platformer* There is a tutorial for how to make one by *Astrum Sensei* The tutorial Playlist is in the Video Description: "Creating A 3D Platformer With Unreal Engine 4" /watch?v=Rl7xxQhp4q8

  • @caster-

    @caster-

    Жыл бұрын

    I'd totally watch it too! These videos are a great resource

  • @acrostiic5623
    @acrostiic5623 Жыл бұрын

    Every time I try to add the Cinemachine Free Look Cam, it always aims at my players feet and doesn't seem to work right. I do everything like in the video but I think maybe theres been an update to Unity because I cant get it to stop looking at the feet/bottom of my character.

  • @BlueAndy_

    @BlueAndy_

    Жыл бұрын

    In the Look At section you dont neccersairley need your whole player, i had the same problem and i just put in the body bone of my character. Worked fine

  • @Lherme
    @Lherme Жыл бұрын

    My character isn't rotating

  • @darkdoom907
    @darkdoom907 Жыл бұрын

    I started watching brooklyn nine nine and realised, I've seen Jake Peralta somewhere

  • @ssk360
    @ssk3609 күн бұрын

    am i the only one getting an orbiting issue with the camera?

  • @blinkachu5275
    @blinkachu5275 Жыл бұрын

    Sad to see that this is the last of the CC tutorials, as one of the most important aspects of a CC isn't tackled. Collision. Yes, the Unity CC has basic collision but not nearly good enough to tackle anything but flat surfaces.

  • @iHeartGameDev

    @iHeartGameDev

    Жыл бұрын

    Latest != last -- There will definitely be more videos in this series!

  • @blinkachu5275

    @blinkachu5275

    Жыл бұрын

    @@iHeartGameDev Ah, fair enough, my bad, read it wrong ^^; Hope to see slopes and other uneven surfaces handled in the future, as your videos are exceptional

  • @Massive-3D
    @Massive-3D Жыл бұрын

    "Learn the code" I will NOT, no matter how simple and easy you make it!

  • @BlueAndy_

    @BlueAndy_

    Жыл бұрын

    You still look at a unity code vid bud... dont know what to tell you

  • @franciscooteiza
    @franciscooteiza10 ай бұрын

    And now this is officially a dead channel.

  • @iHeartGameDev

    @iHeartGameDev

    10 ай бұрын

    New video out Thursday :)

  • @MrSkyAndrea
    @MrSkyAndrea Жыл бұрын

    Just use this code to convert the world-space direction to a camera-space one. direction = Camera.main.transform.TransformDirection(direction); direction.y = 0f;

  • @molten3047
    @molten3047 Жыл бұрын

    I keep getting this error everytime I click W A S or D : Look rotation viewing vector is zero UnityEngine.Quaternion:LookRotation (UnityEngine.Vector3) playerStateMachine:handleRotation () (at Assets/State Machine/playerStateMachine.cs:121) playerStateMachine:Update () (at Assets/State Machine/playerStateMachine.cs:159)

  • @adris4009

    @adris4009

    7 ай бұрын

    same, did you find the solution?

  • @user-hy1xm6ss9l
    @user-hy1xm6ss9l11 ай бұрын

    cameraForward.y = 0; cameraRight.y = 0;

  • @user-hy1xm6ss9l

    @user-hy1xm6ss9l

    11 ай бұрын

    unity says this is not working