THIRD PERSON MOVEMENT in Unity

Sdílet
Vložit
  • čas přidán 7. 06. 2024
  • Let's learn how to make a solid third person controller with a moving camera!
    Jason no longer offers the course mentioned in the video.
    👕Get the new Brackeys Hoodie: lineofcode.io/
    ● Third person controller asset: assetstore.unity.com/packages...
    ····················································································
    ❤️ Donate: www.paypal.com/donate/?hosted...
    ► Join Discord: / discord
    ● Website: brackeys.com/
    ● Twitter: / brackeystweet
    ● Instagram: / brackeysteam
    ········································­­·······································­·­····
    ► All content by Brackeys is 100% free. We believe that education should be available for everyone.
    ❤️ Donate: www.paypal.com/donate/?hosted...
    ········································­­·······································­·­····
    ♪ "ES_Dress Code_Black - oomiee" by Epidemic Sound

Komentáře • 3K

  • @michaelanderson2861
    @michaelanderson2861 Před 3 lety +766

    Bless your soul Brackeys! I miss you evey day

    • @rein556
      @rein556 Před 3 lety +25

      Gave us so much information to us without expecting anything from us

    • @melomaniakjm
      @melomaniakjm Před 3 lety +2

      @@rein556 ahah good one

    • @rein556
      @rein556 Před 3 lety +18

      @@melomaniakjm no I am serious,He really gave us so many tutorials for free

    • @kartavyaseth6582
      @kartavyaseth6582 Před 3 lety +21

      He is not dead 🤣 he only quit youtube

    • @rein556
      @rein556 Před 3 lety +1

      @@kartavyaseth6582 lol 😂😂😂😂🤣😹🤣

  • @Morphinias
    @Morphinias Před 4 lety +3084

    I can already see my brand new unfinished project
    Edit:
    I did not expect a 1000+ likes. Wow!

    • @apainush9540
      @apainush9540 Před 4 lety +31

      That is exactily what i was thinking at

    • @iraklitulashvili2820
      @iraklitulashvili2820 Před 4 lety +11

      Yeah! Lol 😂😂

    • @dgameboss4963
      @dgameboss4963 Před 4 lety +8

      czcams.com/video/Yf9f8eC-Jdk/video.html
      Hey there it's me again DGame_Boss and this time I took a challenge too make a complete Game in 24hrs and the game is a replica of a popular mobile game call ball blast...
      My apologies for spamming you this way...
      Enjoy the video and have a nice day.
      😁

    • @Futureblur
      @Futureblur Před 4 lety +5

      Underrated :)

    • @aludjahjerod8678
      @aludjahjerod8678 Před 4 lety +3

      100%😂😂

  • @Phoenix-0455
    @Phoenix-0455 Před 3 lety +505

    To lock the cursor, use the line 'Cursor.lockState = CursorLockMode.Locked;' in the start function.

    • @WZDRIP
      @WZDRIP Před 3 lety +2

      thanks

    • @davidmaaschdeyck
      @davidmaaschdeyck Před 3 lety +2

      Thats really helpful thank youuuu

    • @davidmaaschdeyck
      @davidmaaschdeyck Před 3 lety +1

      @@WZDRIP And thank you for replying, otherwise i would've scrolled past this comment

    • @just-some-guy-without-a-mo9702
      @just-some-guy-without-a-mo9702 Před 3 lety +1

      I wouldn’t understand anyways, I don’t even have Visual Studio and don’t know how to open my Third Person Controller script on it...

    • @davidmaaschdeyck
      @davidmaaschdeyck Před 3 lety +1

      @@just-some-guy-without-a-mo9702 😮😮😮

  • @SpaceflightRocketShorts
    @SpaceflightRocketShorts Před 3 lety +505

    I was able to watch this video 14 times while waiting for Unity to load...

  • @lucasbonde2
    @lucasbonde2 Před 4 lety +23

    As always, so much quality in the videos! Never gets boring to learn from the Brackeys team!

  • @user-bk5tt8bx1i
    @user-bk5tt8bx1i Před 2 lety +139

    Book Mark
    2:06 Start (The course sounds great!)
    4:38 Free Look Camera
    17:37 Camera clip

    • @akash_the_phenomenal942
      @akash_the_phenomenal942 Před rokem +3

      When I hit Play , camera snaps to different position,(in front upward of the player)
      (It is working fine after that ,when I move mouse it moves the camera accordingly , but snap at starting the game is weird)
      (I have tried locking the cursor in start , but still snap problem exist)
      Why is this Happening , Please Help...

    • @TheSkeleton27
      @TheSkeleton27 Před rokem

      Thanks mate

    • @joecraft9098
      @joecraft9098 Před rokem

      69 likes...
      *Nice*

  • @robotman5105
    @robotman5105 Před 3 lety +170

    I'm extremely appreciative of the fact that he made the code with the intention of being open for customization instead of being specific and restrictive. Literally a perfect video for a basic third person controller.

    • @akash_the_phenomenal942
      @akash_the_phenomenal942 Před rokem

      When I hit Play , camera snaps to different position,(in front upward of the player)
      (It is working fine after that ,when I move mouse it moves the camera accordingly , but snap at starting the game is weird)
      (I have tried locking the cursor in start , but still snap problem exist)
      Why is this Happening , Please Help...

    • @howtoyes8988
      @howtoyes8988 Před rokem +1

      @@akash_the_phenomenal942 Why did you reply to this comment a year later???

    • @akash_the_phenomenal942
      @akash_the_phenomenal942 Před rokem +2

      @@howtoyes8988 I thought when I normally comment on CZcams channel, only channel admin will get the notification and other devs will help me when see my comment, I replied in few of the comments such that they will be get notified and may help me regarding this .

    • @Kasuga-
      @Kasuga- Před rokem

      @@akash_the_phenomenal942 did u put the player game object accordingly? 5:16

  • @ikey07ch
    @ikey07ch Před 3 lety +12

    This was amazing tutorial, I really didnt wanted to use some 3rd person templates, as you never learn what exactly you have to do to achieve it, this was really helpful!

  • @butlerfuqua
    @butlerfuqua Před 3 lety +8

    This is fantastic! I don't think anyone has videos quite like yours. I love how you perfectly balance getting to the point and explaining what's going on. Please keep making videos like this!!!

  • @WuxiaNovelsAudiobookHD
    @WuxiaNovelsAudiobookHD Před 4 lety +19

    I want to say thank you for making these videos! This quarantine made me realize I want to make my own game and your tutorials are my savior. If I end up really making it, I would tag you as my mentor!

  • @masterbuildertristan2494
    @masterbuildertristan2494 Před 3 lety +36

    If any of you are using the High Definition template made by unity, and when testing game you may come along a message in the games window, try adding in the HD aditional camera data component.

  • @Demon.Immortalis
    @Demon.Immortalis Před 2 lety +112

    tip: if u dont want ur camera to move up and down(y-axis) go to y axis in cinemachine and set the speed to 0 :). hope it helps!

    • @bst-music6517
      @bst-music6517 Před 2 lety +2

      Kinda obvious but thanks anyways

    • @nikhilambavaram6006
      @nikhilambavaram6006 Před 2 lety +42

      @@bst-music6517 Not rly. I'm a beginner and I really would've struggled around for a bit without this comment lmao.

    • @cupcakes4100
      @cupcakes4100 Před rokem +1

      Thank youuuu I think I will need that

    • @FleetingDream755
      @FleetingDream755 Před rokem +4

      @@bst-music6517 there's always one...

    • @ethanlittlejohn2536
      @ethanlittlejohn2536 Před rokem

      The character won't turn with my camera, after I copied the top comment's code, can you help?

  • @CP_Maverick
    @CP_Maverick Před 4 lety +20

    This came out at the perfect time. Had the idea for a third person shooter about three weeks ago, struggled to find code that I could easily add functionality on top of, and then I found this video. I've been coming back to it ever since then! Thank you!

    • @janitorscruffy7834
      @janitorscruffy7834 Před 3 lety

      are you still learning game development?

    • @CP_Maverick
      @CP_Maverick Před 3 lety

      @@janitorscruffy7834 Every so often I come back to it, but I think I'm just more of an artist rather than a programmer xD

    • @AdeelNasir121
      @AdeelNasir121 Před 11 měsíci

      Still foing game development ?

    • @CP_Maverick
      @CP_Maverick Před 11 měsíci

      @@AdeelNasir121 Not as much as I should. Ideas keep coming, but the time to properly develop them into vertical slices is never there like I want it to be. I imagine that's the typical struggle for most solo indie devs xD

  • @aaronkanaron
    @aaronkanaron Před 3 lety +837

    If anyone is too lazy to write the code themselves, or just don't know how to do it; Here is my script which includes gravity, jumping, and everything shown in this video. You can also tweak it however fits your game :D
    (Press read more)
    using System.Collections;
    using System.Collections.Generic;
    using System.Collections.Specialized;
    using System.Security.Cryptography;
    using System.Threading;
    using UnityEngine;
    public class ThirdPersonMovement : MonoBehaviour
    {
    public CharacterController controller;
    public Transform cam;
    public float speed = 6;
    public float gravity = -9.81f;
    public float jumpHeight = 3;
    Vector3 velocity;
    bool isGrounded;
    public Transform groundCheck;
    public float groundDistance = 0.4f;
    public LayerMask groundMask;
    float turnSmoothVelocity;
    public float turnSmoothTime = 0.1f;
    // Update is called once per frame
    void Update()
    {
    //jump
    isGrounded = Physics.CheckSphere(groundCheck.position, groundDistance, groundMask);
    if (isGrounded && velocity.y < 0)
    {
    velocity.y = -2f;
    }
    if (Input.GetButtonDown("Jump") && isGrounded)
    {
    velocity.y = Mathf.Sqrt(jumpHeight * -2 * gravity);
    }
    //gravity
    velocity.y += gravity * Time.deltaTime;
    controller.Move(velocity * Time.deltaTime);
    //walk
    float horizontal = Input.GetAxisRaw("Horizontal");
    float vertical = Input.GetAxisRaw("Vertical");
    Vector3 direction = new Vector3(horizontal, 0f, vertical).normalized;
    if(direction.magnitude >= 0.1f)
    {
    float targetAngle = Mathf.Atan2(direction.x, direction.z) * Mathf.Rad2Deg + cam.eulerAngles.y;
    float angle = Mathf.SmoothDampAngle(transform.eulerAngles.y, targetAngle, ref turnSmoothVelocity, turnSmoothTime);
    transform.rotation = Quaternion.Euler(0f, angle, 0f);
    Vector3 moveDir = Quaternion.Euler(0f, targetAngle, 0f) * Vector3.forward;
    controller.Move(moveDir.normalized * speed * Time.deltaTime);
    }
    }
    }

    • @AndenPMS
      @AndenPMS Před 3 lety +58

      God bless you, just tired of trying to learn C# for the past month lol

    • @nagybalint1474
      @nagybalint1474 Před 3 lety +11

      thx i accidentally deleted the wrong script

    • @nagybalint1474
      @nagybalint1474 Před 3 lety +8

      any idea how to trigger animations? I mean I tried to check velocity.x velocity.z but no and if I test if speed is 6 then it is so I need to have speed on 0 and if I hold a button it goes up to 6 or is there any better solution

    • @benjioffdsv
      @benjioffdsv Před 3 lety +13

      Why do you keep System.collections, system.threading and system.security ? These are useless for the script.

    • @Themakingavid
      @Themakingavid Před 3 lety +2

      Thank you, this was extremely helpful

  • @SpaceflightRocketShorts
    @SpaceflightRocketShorts Před 3 lety +432

    Me: making a race car game
    Brackeys: *we can think of the character controller as the motor that drives the player*
    Me: perfect.

  • @kelseyprimar8290
    @kelseyprimar8290 Před 3 lety +2

    This was a great video! Very clear, concise and to the point! Thank you!

  • @ChaosCain4
    @ChaosCain4 Před 4 lety +31

    I'd already made something like this, but seeing it in such a nice package shows how much I have yet to learn. Thanks a lot for such an amazing video, so straightforward and clear

    • @akash_the_phenomenal942
      @akash_the_phenomenal942 Před rokem

      When I hit Play , camera snaps to different position,(in front upward of the player)
      (It is working fine after that ,when I move mouse it moves the camera accordingly , but snap at starting the game is weird)
      (I have tried locking the cursor in start , but still snap problem exist)
      Why is this Happening , Please Help...

    • @ChaosCain4
      @ChaosCain4 Před rokem

      @@akash_the_phenomenal942 Been a while since I did much with this, I'm not sure what you mean. It could be that it's reading the movement of the mouse from the moment you press unity's play button and move down back into the screen. Maybe don't read the mouse inputs on the very first frame of the game if that helps. Besides that I'm not sure, sorry. I hope you find a solution.

    • @-RandomYoutuber--
      @-RandomYoutuber-- Před 11 měsíci

      the script wont let me add the character controller as a controller for it

  • @Sylfa
    @Sylfa Před 4 lety +23

    Please note, changing the camera near clip plane can really create a lot of Z fighting in the distance, or if you go to very extreme numbers, even in the middle distance.
    The reason is how floating points and the Z-buffer works, the Z-buffer stores the pixel depth as a number between 0 and 1, with a bias towards the numbers near the camera (it's non-linear, so 0.1 is not 10% through the distance between near and far clip, but much closer to the camera). And then ofc, the floating point can only store a certain amount of precision, you don't have infinite memory to write down all the decimal points after all.
    Practically this means that most of the Z-buffer is reserved for close to the camera, and by making the near value very small you basically make it so the difference between 100f and 101f is 0f, meaning objects far enough away will start occupying the same distance as far as the Z-buffer is considered.
    In general you want your near clip plane to be the highest you can tolerate in the game, and if you reduce it with an order of magnitude you *should* reduce the far clip with the same magnitude. So from 0.3 - 1000 to 0.03 - 100.
    Though I noticed now that Unity actually prevents you from going under 0.01 as near clip plane to avoid people setting it to 1e-10 and having everything just go wrong. Though you can set the far distance higher to see the effect partially, the near clip plane is more sensitive though due to the non-linear math being used.

  • @baran9086
    @baran9086 Před 3 lety

    I can't say how thankful i am for this video. It really helped me a LOT. Thank you very much!!!

  • @edricko7
    @edricko7 Před 4 lety +3

    Just when I needed this, thanks Brackeys!!!

  • @dauf5093
    @dauf5093 Před 4 lety +3

    I don’t understand some parts of the code yet, but I am making progress over time and I can notice it. I’ve been practicing Unity for quite a time now and found out lots of essential stuff thanks to your tutorials. Keep up the great work.

    • @CloutClan4
      @CloutClan4 Před 3 lety

      Are you still game developing?

  • @thevengefulone2976
    @thevengefulone2976 Před rokem +1

    So far these videos are giving me knowledge of how to build a base reference for a game that I know is going to take a while for me to make even with the help of my team currently still trying to put together 😂

  • @derekw8039
    @derekw8039 Před 3 lety

    I have spent a long time searching the internet for a way to smooth player rotation the way you do here! Thank you thank you THANK YOU!!!!

  • @caderade1742
    @caderade1742 Před 4 lety +11

    I've been banging my head looking for a good tutorial on this!!! Just in time, Tysm :D

  • @gabefoster1737
    @gabefoster1737 Před 4 lety +3

    I don't even use unity but these videos are so entertaining, keep up the good work!

  • @blacky101011
    @blacky101011 Před 2 lety

    So powerful yet so simple! Many thanks!

  • @tolafia6708
    @tolafia6708 Před 2 lety

    Where would i be without this channel...It's too useful for things i forget all the time

  • @loganjones5537
    @loganjones5537 Před 4 lety +50

    Perfect this is exactly what I'm working on!

    • @emmetmayer
      @emmetmayer Před 4 lety +3

      Same, it's kinda creepy

    • @WarpedCyan
      @WarpedCyan Před 4 lety +5

      @@emmetmayer Orr somebody suggest it

  • @pietuuh2065
    @pietuuh2065 Před 4 lety +13

    Finally! I've been waiting for this.

    • @HansBuchser69
      @HansBuchser69 Před 4 lety +1

      Same. The last one broke cus unity updated

  • @sam2chill
    @sam2chill Před 3 lety +12

    I’m glad to see people replying to people who need help, it shows how great a community Brackeys built sad to see him go

    • @fumble8228
      @fumble8228 Před 2 lety +1

      wdym? am i the only person who doesnt know

    • @sam2chill
      @sam2chill Před 2 lety

      @@fumble8228 what bro

    • @ghettosupastar9285
      @ghettosupastar9285 Před 2 lety

      @@fumble8228 Brackeys has quitted making new video's about Game Development in Unity. though he also implied that he might make a comeback nothing is set in stone. he is taking a break

  • @defifire9980
    @defifire9980 Před 2 lety

    This tutorial is the best i've seen for the movement. Congratulations man !! thx you so much

  • @OmAr-ko5vi
    @OmAr-ko5vi Před 3 lety +3

    wow!
    I AM SEARCHING FOR THIS FROM A LONG TIME
    AND EVERYONE HAVE HIS WAY AND THE MOST OF THIS WAY DOES NOT WORK
    BUT YOU DIT IT
    THANK YOU VERY MUCH

  • @MagdaMuffin13
    @MagdaMuffin13 Před 4 lety +11

    You're really bringing me through my studies right now.... thank you so much!

  • @rasuku7353
    @rasuku7353 Před rokem +1

    Thanks!!!This video has what I was looking for!!

  • @TheHanskiH
    @TheHanskiH Před 7 měsíci

    This helped me a lot, i was struggling with movement and camera composition. But with your help, i manage to do the style i was looking for.... Thanks

  • @puchinbold
    @puchinbold Před 3 lety +193

    He always looks like he's about to start laughing

    • @dexah4842
      @dexah4842 Před 3 lety +4

      i imagine him just going "ccch-chhh" the whole video

    • @nazarya5547
      @nazarya5547 Před 3 lety +7

      İ don't think he looks like he will laugh he just looks happy.

    • @TheMerchant3773
      @TheMerchant3773 Před 3 lety +2

      @@nazarya5547 yeah

  • @KvnLeandro
    @KvnLeandro Před 4 lety +6

    That was exactly what i need right now, i love this channel so much

  • @caseyco21707
    @caseyco21707 Před 2 lety

    This worked for me, and the results are stunning. Thanks.

    • @akash_the_phenomenal942
      @akash_the_phenomenal942 Před rokem

      When I hit Play , camera snaps to different position,(in front upward of the player)
      (It is working fine after that ,when I move mouse it moves the camera accordingly , but snap at starting the game is weird)
      (I have tried locking the cursor in start , but still snap problem exist)
      Why is this Happening , Please Help...

  • @nishantrishinair854
    @nishantrishinair854 Před rokem

    ! I was trying to make a third person camera system for my game but it wasn't really working. Despite the differences in setup, this worked for me without having to change much. Thanks for making this tutorial so flexible/customisable

  • @laurenwilkerson2435
    @laurenwilkerson2435 Před 3 lety +124

    Fyi in Unity 2019.4 "All Packages" has been Renamed to "Unity Registry"

  • @erikaburahmanov5215
    @erikaburahmanov5215 Před 4 lety +3

    I am following for about 5 months and I am making huge progress with your tutorials. You are cool guys. If it is possible could you make a tutorial more about third-person control and more about importing 3D fbx models to unity

  • @tyraresgame
    @tyraresgame Před 3 lety

    You saved my life, my final project and my times....Thanks you very much

  • @XxdeadloicxX
    @XxdeadloicxX Před 2 lety +6

    Great video ! Just one thing, if you normalized your direction vector it'll be useless to check if its length is greater than 0.1 (if you do this to simulate a stick deadzone).

  • @JesusSkywalker92
    @JesusSkywalker92 Před 4 lety +8

    I've noticed that whenever you make a controller that uses a cylinder or capsule as the base, you make the scale 1.8 on the y axis (being 1.8 metres is the average height for a person) but the base height of cylinders and capsules is unity is 2 metres high on the y axis so by making is a scale of 1.8 you're essentially making a person that's 3.6 metres tall.

    • @peterkovac1406
      @peterkovac1406 Před 2 lety

      as long as you keep proportions its ok, like map scale

  • @andrewericliu3845
    @andrewericliu3845 Před 4 lety +938

    Me : Works for hours writing camera collision code.
    Cinemachine: Does it in two clicks.
    Me: 0_0

    • @Wodsobe
      @Wodsobe Před 4 lety +11

      i can relate to this lol

    • @CristianCardosoMendesAntiMark
      @CristianCardosoMendesAntiMark Před 4 lety +26

      i did my script in seven hours, with a bad smoothing, i am really sad

    • @TotatoC
      @TotatoC Před 4 lety +7

      lmao same here

    • @rogerpatino3000
      @rogerpatino3000 Před 4 lety +32

      I have the opposite problem. Before I implement ANYTHING, I obsessively look up resources online for hours to see if it has already done and I can just use someone else's method.

    • @warlock1080
      @warlock1080 Před 4 lety +2

      It's literally what I was trying to get figured out the past couple days. then I look at this... Thank you!!

  • @GemGameDev
    @GemGameDev Před 9 měsíci

    Too sad you stopped making videos here, I still watch your stuff on a regular basis. Thanks for creating!

  • @mohammedalmughery7821
    @mohammedalmughery7821 Před 3 lety

    Thx ALOT brackeys I really appreciate the lessons u gave us

  • @davegamedevelopment
    @davegamedevelopment Před 4 lety +2

    Haha love the intro! Thanks a lot for the tutorial! :D

  • @UniSolJeroen
    @UniSolJeroen Před 3 lety +10

    I had been trying so hard to get my player movement to work right with my camera movement the past few days and couldn't figure out this last missing part, and then find this video and noticed how easy it is if only I had brushed up on my math some more. Also, cinemachine... I forgot it existed... **buries head in hands**

  • @baharprogrammer2957
    @baharprogrammer2957 Před rokem

    Thanks for your help today, your video is the best way to game development in unity

  • @GamicoMart
    @GamicoMart Před 2 lety

    Amazing man amazing no one provide free knowledge like this its ridiculous....
    I checked out 20 channels on you tube but no one is like you💥

  • @quoipi
    @quoipi Před rokem +52

    For anyone looking for the Cinemachine dropdown menu, it is now accessed by right-clicking in the Hierarchy tab. If you do this and Cinemachine is not present down the bottom, try right-clicking inside your Project tab and clicking Reimport All.

    • @luigimich_
      @luigimich_ Před rokem

      thanks man, really helped me out

    • @brodymortensen1004
      @brodymortensen1004 Před rokem

      for me i found cinemachine in the GameObject tab

    • @quoipi
      @quoipi Před rokem +1

      @@brodymortensen1004 That's because the GameObject tab is the same as the menu that appears when you right click in the Hierarchy tab.

    • @brodymortensen1004
      @brodymortensen1004 Před rokem

      @@quoipi Oh my bad man! I'm still a little new too unity!

    • @quoipi
      @quoipi Před rokem +1

      @@SamTheTourists That's because the GameObject tab is the same as the menu that appears when you right click in the Hierarchy tab.

  • @frankeeeej
    @frankeeeej Před 4 lety +22

    For camera-relative inputs I always use this line in my playerController:
    " movInput = (Cam.transform.forward * Input.GetAxisRaw("Vertical")) + (Cam.transform.right * Input.GetAxisRaw("Horizontal")); "
    Which is just one line of code and therefore superior ;p
    Apart from that, this cinemachine setup is waaaay superior than anything I ever made by myself, so I shal copy this for future projects, haha

    • @thomasdaly7270
      @thomasdaly7270 Před 4 lety

      yea man I rate this

    • @akash_the_phenomenal942
      @akash_the_phenomenal942 Před rokem

      When I hit Play , camera snaps to different position,(in front upward of the player)
      (It is working fine after that ,when I move mouse it moves the camera accordingly , but snap at starting the game is weird)
      (I have tried locking the cursor in start , but still snap problem exist)
      Why is this Happening , Please Help...

  • @BurakHerdem
    @BurakHerdem Před rokem +1

    This tutorial was so good that I could feel the third person movement coming inside me whenever i played my game

  • @nitrogaming7565
    @nitrogaming7565 Před 11 měsíci

    Amazing tutorial really easy to understand love this and you❤❤❤

  • @georgeorwell4891
    @georgeorwell4891 Před 4 lety +7

    I swear, this guy is a psychic.

  • @VerySus
    @VerySus Před 4 lety +419

    My brain started hurting when he started saying things like Euler and Quaternion...

    • @Pxlarizar
      @Pxlarizar Před 4 lety +19

      It’s just something y have to suffer through when your a dev

    • @PetersExcapades
      @PetersExcapades Před 4 lety +74

      ill try to explain it simply, think of Quaternion as a Vector3 with an extra value, or Vector4 for example, the quaternion has x, y, z, and w, it is really hard for us humans to visualize the w rotation, so we have Euler angles, if u do Quaternion.Euler(new Vector3(0, 90, 0)); this will create a quaternion that will turn ur character 90 degrees to the right (all rotation is clockwise). Euler() takes a vector3, transform.rotation uses Euler angles

    • @PetersExcapades
      @PetersExcapades Před 4 lety +4

      if u need more explanation let me know

    • @omergg4170
      @omergg4170 Před 4 lety

      yea me too

    • @omergg4170
      @omergg4170 Před 4 lety +6

      @@PetersExcapades Aaaaa... i don't think i understood anything

  • @protpus1750
    @protpus1750 Před 3 lety

    amazing tutorial, i found what i need to learn. you won a subscriber, good video bro

  • @linesthatmove
    @linesthatmove Před 3 lety

    This was such a great tutorial!!!

  • @puruarora3584
    @puruarora3584 Před 4 lety +4

    Finally ❤❤
    Pls pls also make a video on humanoid movements...i am tired of using ethan🌚🌚

  • @anotherperson3450
    @anotherperson3450 Před 3 lety +20

    It would be nice if this has a next part with animated character like running jumping and etc

    • @flint8182
      @flint8182 Před 3 lety

      i would recommend watching seabastian league

  • @justusedforstuff4391
    @justusedforstuff4391 Před rokem

    awesome video thanks really helped me undrstand it and ive used this for my school project

  • @halimebeyzacicek8440
    @halimebeyzacicek8440 Před 2 lety

    so useful and clear. i loved

  • @JelleVermandere
    @JelleVermandere Před 4 lety +139

    Aah, the infamous cilinder-cube man, ready to boldly go where none have gone before!

    • @thekillerduck6977
      @thekillerduck6977 Před 4 lety

      Lol

    • @hypehextech4680
      @hypehextech4680 Před 4 lety

      yo Jelle! wassup

    • @JelleVermandere
      @JelleVermandere Před 4 lety

      HypehexWorks #neverstoplearning

    • @hypehextech4680
      @hypehextech4680 Před 4 lety +1

      @@JelleVermandere xD nice

    • @dgameboss4963
      @dgameboss4963 Před 4 lety

      czcams.com/video/Yf9f8eC-Jdk/video.html
      Hey there it's me again DGame_Boss and this time I took a challenge too make a complete Game in 24hrs and the game is a replica of a popular mobile game call ball blast...
      My apologies for spamming you this way...
      Enjoy the video and have a nice day.
      😁

  • @FaithBasedBiz
    @FaithBasedBiz Před 3 lety +8

    I'm woking on a third person game with Legos, and this saved me from quitting, I'm serious, I was gonna stop making the game! TYSM, Brackeys! 😊

  • @sir.niklas2090
    @sir.niklas2090 Před rokem +1

    Thanks for the tutorial!

  • @kzysz3904
    @kzysz3904 Před 3 lety +1

    I was fighting with camera and player movement for a few weeks... After 20 minutes of this video this is better than everything that I got....

  • @Futureblur
    @Futureblur Před 4 lety +738

    I now know that I know nothing.

    • @tacomixen
      @tacomixen Před 4 lety +14

      Finally Jon Snow.

    • @chocpix
      @chocpix Před 4 lety +22

      I know what the best symbol is...
      [ ]
      The symbol of *brackeys*

    • @chocpix
      @chocpix Před 4 lety +5

      Yet... I know nothing else...

    • @ariarichards-
      @ariarichards- Před 4 lety +2

      Nice rhyme rap

    • @salihcanozdemir2112
      @salihcanozdemir2112 Před 4 lety +1

      play.google.com/store/apps/details?id=com.UrazSoftware.StickyBall

  • @Drag-kv6rr
    @Drag-kv6rr Před 3 lety +3

    Ok i'm whatching these video rn and I wanted to tell you : "WoW" I'm in high school but I've seen that the real programming is soooo different, I admit that I'm having a lot of difficulties and the temptation of giving it away and just copy the code is really big but actually I'm here to learn not to copy so thank you for your explainations, I really appreciate how you make it look so simple, it is very motivational, God bless you!

    • @insanityyyy
      @insanityyyy Před 2 lety +2

      dont stop urself from copy and pasting , i learnt c# by copy and pasting different things i wanted together into one script , it helped me understand it alot more

  • @pol3824
    @pol3824 Před 2 lety

    Once again amazing tutorial!

  • @FrancybelloCoding
    @FrancybelloCoding Před 3 lety +1

    awesome video !! thank you so much!
    😀

  • @furkanpoyraz8008
    @furkanpoyraz8008 Před 4 lety +6

    Awesome video! Would've been even better with the new input system, since v1 is officially out it might be worth checking out.

    • @l2hetoric
      @l2hetoric Před 3 lety +1

      Takes a bit of tweaking but works well with the new input system. Just haven't figured out how to manage the movement angle in relation to the camera using the new input yet

    • @MAxAMILLIoN757
      @MAxAMILLIoN757 Před 2 lety

      @@l2hetoric Please reply here with the code if you figure it out

  • @jealouscase3634
    @jealouscase3634 Před 4 lety +3

    Hey Brackeys, if you have not already, do you think you could make a video covering voxel animation? I know there are already tutorials out on this subject, but I'm sure your explanation would be the most straightforward and beneficial.
    If you see this, thanks!

  • @safdardeveloper3804
    @safdardeveloper3804 Před rokem

    You are the only one youtuber who kept the contents simple and useful

    • @Viltzu-hk5wh
      @Viltzu-hk5wh Před rokem

      Yeah, but like all people the man gotta have his own time. we owe him at least that much.

    • @safdardeveloper3804
      @safdardeveloper3804 Před rokem

      @@Viltzu-hk5wh I don't know what you mean.

  • @rjua1
    @rjua1 Před 3 lety

    Soooo hopeful. Thank you very much!!!

  • @parvayalar3686
    @parvayalar3686 Před 3 lety +4

    In the last part instead of creating movDir, use transform.forward. transform.forward points in the current forward direction of the Player Object.
    controller.Move(transform.forward * speed*Time.deltaTime);

  • @iangraham6730
    @iangraham6730 Před 4 lety +4

    Jason is top class, have been following him for a long time, well worth a sub!

  • @matteocarlascio8531
    @matteocarlascio8531 Před 3 lety

    Love u man!! It really helped me out!!

  • @user-chuquangvuong
    @user-chuquangvuong Před 5 měsíci

    How you provide the information is so interesting and easy to understand man, you got one subscribe !

  • @zill4_
    @zill4_ Před 4 lety +22

    How would this work if you want gravity?
    [edit]x2 Below is my code, the main difference is that I am using a rigid body and gravity.
    Also to note that his rotation is always 'smoothing' so it never comes to rest, which is why I just use the just the target angle.
    translation = Input.GetAxisRaw("Vertical");
    straffe = Input.GetAxisRaw("Horizontal");
    vSpeed -= gravity * Time.deltaTime;
    movement = new Vector3(straffe, 0f, translation).normalized;
    if (controller.isGrounded)
    {
    // Jumping, if we are on the ground, v goes back to 0.
    vSpeed = 0;
    if (Input.GetKeyDown("space")){
    vSpeed = JumpForce;
    }
    }
    // movement rotation
    float targetAngle = Mathf.Atan2(movement.x, movement.z) * Mathf.Rad2Deg + cam.eulerAngles.y;
    transform.rotation = Quaternion.Euler(0f, targetAngle, 0f);
    // if vertical/horizontal are active isMove is True (1) else False (0)
    isMove = (( translation != 0 || straffe != 0) ? 1 : 0);
    // Direction for us to move given that motion is present (isMove)
    Vector3 moveDir = Quaternion.Euler(0f, targetAngle, 0f) * (Vector3.forward * isMove);
    // Gravity acting on us.
    moveDir.y = vSpeed;
    // Movement
    controller.Move(moveDir.normalized * Speed * Time.deltaTime);

    • @uv21
      @uv21 Před 3 lety +2

      what is cam.euler angles because unity says cam.euler angles out of context

    • @youtubestarter6664
      @youtubestarter6664 Před 3 lety +3

      @@uv21 I think he forgot to copy the line "public Transform cam;" at the top so you get an error cause unity doesn't knwo what cam is (ps sry for my bad english)

    • @nachiketmore9068
      @nachiketmore9068 Před 3 lety +1

      Could you send the entire code. I know its been a year but still I can use it..

    • @mateodemicheli2420
      @mateodemicheli2420 Před 2 lety

      @@nachiketmore9068 Same here bro pls

    • @rayanesaada5080
      @rayanesaada5080 Před 2 lety

      what is vSpeed?

  • @BamassacreGaming
    @BamassacreGaming Před 3 lety +18

    Me coming into life always wanting to code games.
    Me hearing Quaternion.Euler and looking back at my code and getting a migraine

  • @zhenkaichen3759
    @zhenkaichen3759 Před rokem

    It's what i need!Thank you!

  • @samoldfield9997
    @samoldfield9997 Před 6 měsíci

    thank you sir and your team. your works are the best

  • @flannagus4787
    @flannagus4787 Před 3 lety +4

    yes yes it worked! now im feeling a surge of dopamine, thats sure to stop after some time, thanks!

  • @fatboyvlogs5648
    @fatboyvlogs5648 Před 4 lety +3

    HOLY SHITE MAN! I was looking for this from past 2 weeks ILY(no homo)!

  • @literallydrdrey
    @literallydrdrey Před 3 lety +1

    Thanks For Brackeys!

  • @a_carotyt8589
    @a_carotyt8589 Před 2 lety +1

    Wish you still posted. this helped SO MUCH!

  • @efaz6809
    @efaz6809 Před 4 lety +6

    OMGGG YESSS. I NEEDED THISSSSSSS.
    I usually prefer doing everything myself. So cinemechine is something I dnt really like. Luckily I know how to make my own 3rd person camera and collision. Then apply the movement script to it. Thanks so much brackeys ur the best!

    • @ArnoldsKtm
      @ArnoldsKtm Před 4 lety +1

      I get what you are saying but in terms of real-world applications this is a godsent package. It does so much for you and saves so much time. And time is money. No need to reinvent the wheel.

    • @dgameboss4963
      @dgameboss4963 Před 4 lety

      czcams.com/video/Yf9f8eC-Jdk/video.html
      Hey there it's me again DGame_Boss and this time I took a challenge too make a complete Game in 24hrs and the game is a replica of a popular mobile game call ball blast...
      My apologies for spamming you this way...
      Enjoy the video and have a nice day.
      😁

    • @efaz6809
      @efaz6809 Před 4 lety

      ArnoldsK Yh I get wht ur saying but I’m kind of still learning. So doing this will, in a way make me more confident with the things I’m learning, as everything I produce is made from scratch by me. It’s hard to explain but yh

    • @efaz6809
      @efaz6809 Před 4 lety

      DGame Boss video’s been removed

  • @666nevermore
    @666nevermore Před 3 lety +5

    How do you convert those values into a rigid body? working with character controller is almost useless, you can't interact with most of things. I tried a couple of ways but it seems like RigidBody doesn't like that Vector3 moveDir for some reason

  • @afvc6174
    @afvc6174 Před 2 lety +1

    it really awesome!

  • @novarl4115
    @novarl4115 Před 2 lety

    i love how this dude isnt even making content anymore and his stuff is still the first thing to show up when i search literally anything unity related

  • @soceity7102
    @soceity7102 Před 4 lety +158

    Sees this video after 1 month of working on third person movement
    Me: internal screeching

  • @YE55INE
    @YE55INE Před 3 lety +38

    If anyone's having snappy movement when going from a direction to the opposite one just uncheck "snap" in project settings-axis

    • @chalie42
      @chalie42 Před 3 lety +6

      Thank you VERY much

    • @higorss
      @higorss Před 3 lety +2

      where do i find ''project settings-axis'' ???

    • @subarunatsuki1902
      @subarunatsuki1902 Před 2 lety

      @@higorss Did you found it?

    • @higorss
      @higorss Před 2 lety +1

      @@subarunatsuki1902 I don't remember sorry. I gave up on my game dev career

    • @subarunatsuki1902
      @subarunatsuki1902 Před 2 lety

      @@higorss No Problem, thx anyway :D

  • @furiag9664
    @furiag9664 Před 3 lety

    Thank you for everything!!

  • @DistorsionMentalBuzz
    @DistorsionMentalBuzz Před 2 lety

    I was so excited with what i had learned so far, i only wanted to know how to rotate a character's direction. after watching this i feel so overwhelmed. :( that's awesome btw

  • @Zinisco
    @Zinisco Před 4 lety +3

    It's like Brackey's knew that I wanted to make a third-person perspective game

  • @olqb9532
    @olqb9532 Před 3 lety +4

    I'm quite new to this, a lot of tutorials recommend to have the actual movement in FixedUpdate. Is there a specific reason Brackeys does it differently? I get that Time.deltaTime works around the fps resctrictions, but to my understanding it would still be best practice to have it in FixedUpdate. What am I missing?

    • @Kazuma593
      @Kazuma593 Před 3 lety +4

      I'm new as well, but I do know the reason for that. FixedUpdate is the update for the physics engine which runs on a fixed interval. Update happens every time a frame is rendered. If people bind things to Update instead of Fixed Update, the more FPS you have, the more often your functions are being called.
      That's also what creates weird issues with games like Elder Scrolls or Fallout, so usually they just add a 30 fps cap instead of tying it to something other than frame rate.
      With Unity we can use FixedUpdate to tie it to the interval refresh of the physics engine. This way whether you get 1fps or 144fps the lines of code are still executed in the same interval.

  • @solitaryrocky1541
    @solitaryrocky1541 Před rokem

    Thank you so much for this. I learned a lot following along. Way more than what was taught by my lazy professor in university. 😂

  • @user-dw8lv6sy2y
    @user-dw8lv6sy2y Před 3 lety

    3인칭으로 프로그램을 만들게 될 것 인가 아니면 1인칭으로 프로그램을 만들게 될 것 인가는 큰 고민 중 하나였습니다. 이런식으로 각각의 장단점에 대해서 자세히 설명해주시고 특징들을 잘 짚어내어 주셔서 선택을 하는데에 큰 도움이 되었습니다.

  • @Zaine7673
    @Zaine7673 Před 3 lety +5

    This script seems so elegant 😍 but how can you adjust it so player moves backwards when you press S instead of turning around and facing that way?

    • @jmas2593
      @jmas2593 Před 2 lety

      I wanna know this too