Move and Animate a 3rd Person Character in Unity3D

แชร์
ฝัง
  • เผยแพร่เมื่อ 25 ส.ค. 2024

ความคิดเห็น • 114

  • @hoax-games
    @hoax-games 3 ปีที่แล้ว +80

    Very useful video. There is one small little bug though. velocityZ and velocityX are normalized so if you move for example to the top right, the values will be both ~0.707. However in the animator the values required for the top right animation to play are set to require both values to be 1. This will never happen. This can be easily fixed by adapting the values in the animator.

    • @trashcaster
      @trashcaster 2 ปีที่แล้ว +4

      You can also have a normalized variable for velocity, and an un-normalized variable for input. This lets you keep track of the player's input separate from the velocity (in case you want to read inputs, but keep the player from moving, say during a cut scene, or maybe a mini-game type interaction within the game). You can also get nice movement by having your input act more as an accelerator than a direct movement, which could be useful when your game has things like ice, and you want to make the inputs apply to the movement with lower strength, to give the effect of slipping/sliding.

  • @petrosaslanidis
    @petrosaslanidis 3 ปีที่แล้ว +29

    I like that Jason explain every line of code.

  • @bovineox1111
    @bovineox1111 ปีที่แล้ว +1

    Waiting for a recall on my car today at the dealership and decided to dig into this area which I am, at best rusty at, and every video I hit on was from Jason Weimann. All super useful, doing a good job of refreshing my noggin and educating me. Thank you.

  • @pwnzor89
    @pwnzor89 3 ปีที่แล้ว +12

    I wish we had this a year ago, we made an 8 directional nav controller for an isometric top down game in unity with joysticks and LET ME TELL YOU WHAT, our code is wwwwaaaaayyy longer than 45 lines. haha This is extremely helpful, you never know what your next video will do for a team! thanks so much for keeping at this thing, it helps so much for those of us that didn't go to college and are figuring out what coding is. You. Rock. :)

    • @mrworldwide9172
      @mrworldwide9172 2 ปีที่แล้ว +3

      don't worry even those who go to college are figuring out what coding is and how things work 😂

  • @Roundbeargames
    @Roundbeargames 3 ปีที่แล้ว +7

    brutally simple and effective! this is the best video i've seen on animating a tps character. can't wait to see the full game!

  • @quietackshon
    @quietackshon 3 ปีที่แล้ว +3

    Thanks for showing how to setup the animations, the code control and "how-to" blendtree.
    You mentioned "animation driven movement", as well as "root motion", are these the same, and how can they be incorporated into the game character animation work flow.
    Your tutorials are very helpful for beginner/intermediate developers.

  • @phirewind
    @phirewind 3 ปีที่แล้ว +1

    Just wanted to say that the fact that you and Charles don't both have at least an order of magnitude more views is an indictment on TH-cam's ability to get actual useful videos in front of budding (and aging) developers. Keep up the good work, Unity has evolved so much just in the past 2 years that I've struggled to keep up while not doing it full-time.

  • @PointToBlank89
    @PointToBlank89 2 ปีที่แล้ว +3

    Thank you for this, awesome tut! One other suggestion, where you set the Root Transform Rotation, you can change Based Upon field to Original, that will inherit the original rotation from Mixamo, which works great for their animations and should re-center your model.

  • @Husmanmusic
    @Husmanmusic 3 ปีที่แล้ว +2

    These videos are just soo great, esspecially the deeper explanations of what everything does. Thanks Jason!

  • @AllDayBikes
    @AllDayBikes 3 ปีที่แล้ว +3

    This looks a lot easier than blending between states, never seen the blend tree before. Although the last time I dealt with animation within unity was a few years ago

  • @levayv
    @levayv 2 ปีที่แล้ว

    Thanks a lot for "Lock" feature

    • @levayv
      @levayv 2 ปีที่แล้ว

      21:06

  • @dragoneye2640
    @dragoneye2640 3 ปีที่แล้ว +14

    For Mixamo animations, you can change the "Root Transform Rotation" to base upon the other option "Original"-something. I found that it adds the proper offsets automatically to the clips I imported.

    • @vyacheslav2293
      @vyacheslav2293 3 ปีที่แล้ว

      saved me lots of time in future by saying this!

  • @lefterisk1872
    @lefterisk1872 2 ปีที่แล้ว +1

    If you are working on a mobile game with joystick and want to blend from run to walk based on stick's position, just add them to the blend tree at 0.5 and remove .normalized from Dot.

  • @montanas_code
    @montanas_code 3 ปีที่แล้ว

    I wasn't finding some variant to change coordinates from one decart coord system to another rotated with center at the same position. But u know how can it simple and smart! U re awesome !

  • @DePistolero
    @DePistolero 3 ปีที่แล้ว

    Awesome, after finding out about blend tree, that is the only thing I every use to animate character great approach.

  • @djProduct2008
    @djProduct2008 3 ปีที่แล้ว +9

    5:28 The naming mistake is that you don't put an underscore on a local variable "direction". The underscored convention "_direction" implies that the variable is a private field of its class.

    • @fejza
      @fejza 3 ปีที่แล้ว +1

      Not really a mistake and personal preference. Prefixing private fields with "_" is actually against the official C# naming guidlines. But a lot of people like to do it. A lot of people don't do it.

    • @fejza
      @fejza 3 ปีที่แล้ว +1

      If you want to learn more about official naming guidlines here's the source: docs.microsoft.com/de-de/dotnet/standard/design-guidelines/names-of-type-members

    • @djProduct2008
      @djProduct2008 3 ปีที่แล้ว +1

      @@fejza Thanks, but I'm well acquainted. You've missed the point a bit. He used an underscore naming convention with a local variable, not a private field. That would communicate that the local variable was a private field to most developers. So, I'd agree either way. You're right, it's not technically a naming "mistake". At the same time, I would have serious problems with any developer suggesting underscores for local variables project-wide is a sound idea. It's poor code communication and something that should be corrected, kind of like a mistake would be.

    • @fejza
      @fejza 3 ปีที่แล้ว +1

      @@djProduct2008 thanks. Sorry my bad. It was late a night haha. I agree, naming local variables like that may spawn a lot of confusion. I've actually seen people doing that a couple of times as well.

    • @djProduct2008
      @djProduct2008 3 ปีที่แล้ว

      ​@@fejza No worries man! I'm a big fan of the Microsoft naming convention guidelines in my professional LOB work. I find them hard to adhere to with Unity C# sometimes. The first time you sit in front of a MonoBehaviour with public fields as a norm, as an experienced C# dev, and survive the shock and horror, and turn ReSharper off for a while, we realize this isn't C# Kansas anymore.
      Some concessions do have to be made in Unity with regards to naming conventions or even good practice (like public fields vs our standard approach encapsulated properties) or countless other issues in order to support the Unity Editor, design-time variables, performance reasons, etc.
      So, be careful hitting too many potentially terrified C# newbies over the head with that book of guidelines in this particular culture of C#. It's great intel, I agree, but it's only so helpful in this ecosystem.

  • @mezzanine510
    @mezzanine510 3 ปีที่แล้ว

    Your dot product solved my problem, thanks a ton man!

  • @gabrielplourde6791
    @gabrielplourde6791 3 ปีที่แล้ว +1

    So many informative videos. I hope you aren’t burning out, we need you! :D

  • @Brian-vs9sd
    @Brian-vs9sd 3 ปีที่แล้ว

    I'm really enjoying all this content Jason.

  • @poochy661
    @poochy661 2 ปีที่แล้ว

    7:00 I would only normalize the movement vector if magnitude > 1, since if you are using a controller, you may actually want a movement vector less than 1 for stuff like walking or in general more controlled movement

  • @gzayorvus3195
    @gzayorvus3195 3 ปีที่แล้ว

    Really amazing and straight to the point, thanks a bunch!!

  • @androvisuals6863
    @androvisuals6863 3 ปีที่แล้ว

    As always an amazing video! Thank you so much for taking the time to create such amazing tutorial content

  • @NguyenHoangPhuong-qf6xb
    @NguyenHoangPhuong-qf6xb 3 ปีที่แล้ว +1

    How do you make Camera follow, I use Cinemachine Cam and method AimAtMouse() completely broke up all (because of Cinemachine Virtual Camera must Follow player, but cant handle that with your method changing transform.forward)

  • @SentinelaGames
    @SentinelaGames 3 ปีที่แล้ว

    Thank you very much, knowledge is always welcome.

  • @5252emre
    @5252emre 3 ปีที่แล้ว +3

    17:51 when i set up the transform rotation i change body rotation to original then u dont need to adjust the offset

  • @nGAGE0nline
    @nGAGE0nline 3 ปีที่แล้ว +3

    local variable "underscore"direction? :D
    Why would you update transform on an actor with a rigidbody?
    Also, wouldn't your diagonal animations never play at their respective full animation-speed? (you'll never have a value of (-1,1) since your Velocities are normalized? Seems like it would need to be something closer to -0.7, .0.7 for example... or maybe I'm just overthinking it)

  • @Director414
    @Director414 ปีที่แล้ว

    Great video! :) Many thanks!
    how would i modify this script to accept more nodes in the Blend Trees, the "2D Freeform Directional setting"? If I want to include running, and maybe crouching and jumping etc?

  • @unityalexdev
    @unityalexdev ปีที่แล้ว

    What is the soft used for mouse click high lights ???

  • @bonse2000
    @bonse2000 2 ปีที่แล้ว

    when i move my character and rotate the camera the buttons messed up for example when i press w the player move right if i press d then player move backwards s player move left a player move forward

  • @creaturecove7544
    @creaturecove7544 3 ปีที่แล้ว

    Great info, thank you.

  • @mrCreepsy
    @mrCreepsy 3 ปีที่แล้ว +3

    1:24 So you say we forget the Like Button then

    • @videowatcher8874
      @videowatcher8874 3 ปีที่แล้ว

      "P.S. Please forget the Like button"
      Gotta love it.

  • @halivudestevez2
    @halivudestevez2 2 ปีที่แล้ว

    Capsule + Rigid vs CharacterController ... always a big question

  • @tejasbele1456
    @tejasbele1456 3 ปีที่แล้ว

    Thank yo so much
    You really saved me : )

  • @webunlocked
    @webunlocked 3 ปีที่แล้ว

    Really great content!

  • @amac333
    @amac333 3 ปีที่แล้ว

    great vid, thanks.

  • @among4684
    @among4684 3 ปีที่แล้ว

    SO HELPFULLL THX!!!!

  • @frankf1667
    @frankf1667 3 ปีที่แล้ว

    This is very useful, but how do you make the character move faster (as in many games) by holding down the Shift key for example?

  • @SantinoDeluxe
    @SantinoDeluxe 3 ปีที่แล้ว

    if you want to build a simulation controller where one thumbstick controls a limb (say a leg) and collision dictates movement... where would you start? what would you call that?
    i know its too high level for me but thats the direction i want to head. thanks for your help

  • @5252emre
    @5252emre 3 ปีที่แล้ว

    when i blend a second animation layer for the upper body its looking weird. i try to combine the pistol animations with rifle 8 way animations

  • @neothespankplank5839
    @neothespankplank5839 3 ปีที่แล้ว

    Why does the diagonal movement work with animations? The normalized values will never be (-1, 1) for example. Is it because the values of 0.7(ish) are closer to 1 than to 0? I am kinda confused :D

  • @raingamedev702
    @raingamedev702 3 ปีที่แล้ว

    Hi Jason, which controller do you use to develop / play? And do you use different controllers for games and dev or just one? thanks!

  • @neozoid7009
    @neozoid7009 ปีที่แล้ว

    is you rig in humanoid ?? because my animation there is no option for offset

  • @bounames
    @bounames 3 ปีที่แล้ว

    Hi Jason, thanks for the tutorial. Adding a small float of 0.1sec on the animator.setfloat messes up my animation events especially with those used for foot step sounds. Do you have a work around?

  • @LuRybz
    @LuRybz 3 ปีที่แล้ว

    Jason, one problem I ALWAYS face in my projects is the need of a Factory of Prefabs.
    Oftenly I need a reference of a prefab in some strange place. The ideal is to have an static function that could create the thing and already dealing with the prefab dependency.
    Any ideas?

  • @KroneDev
    @KroneDev ปีที่แล้ว

    Why does the title say 3rd person when it means top down or isometric?

  • @Shadowjones
    @Shadowjones 2 ปีที่แล้ว

    When I change the rotation of my character, the animations don't recognize transform.forward. It seems transform.forward is using world space and Im not sure as to why.

  • @gower1973
    @gower1973 3 ปีที่แล้ว

    Hi Jason, on the animation preview there is a red arrow under his feet, but its not pointing straight, what is that arrow and should it point towards the blue arrow?

  • @surgesteelshot8617
    @surgesteelshot8617 ปีที่แล้ว

    can someone post the full code it doesn't let me see the whole thing.

  • @macleodgordon
    @macleodgordon 3 ปีที่แล้ว

    Just downloaded the Robot using your link above, placed it on a 3d-plane, but under the Player Movement script, there is no 'Aim Layer Mask', just the variable 'Speed'. Also under Art/Robot where you chose the Idle animation. I have nothing but 'Player' under Art/Robot. Where is all this stuff you are talking about Jason? :(

  • @SpawnCampGames
    @SpawnCampGames 3 ปีที่แล้ว

    did u prefer to use var direction? otherwise didnt see it

  • @nocultist7050
    @nocultist7050 3 ปีที่แล้ว

    Tell my why Vertex Snapping in unity is still broken and how am I supposed to tile my 3D modular levels without seams...

  • @random_precision_software
    @random_precision_software 3 ปีที่แล้ว

    Do you find you NEED to user the get component in start there's been time I've forgot to put them in and they worked fine!?

  • @michaelwilson8461
    @michaelwilson8461 3 ปีที่แล้ว

    Anyone know if he got around to that next video he mentioned at the end?
    Would like to see that one.

  • @Thesupperals
    @Thesupperals 3 ปีที่แล้ว

    Could someone explain to me what it means to "bake into pose"? I don't understand more than half of the terms Unity uses and it becomes very confusing when you're coming from blender where you Bake a material into a texture.

  • @azgan123
    @azgan123 3 ปีที่แล้ว

    Hey Jason, thanks for the vid. If I'm blending animations with events how do i know which event will play?

  • @kemshura1566
    @kemshura1566 3 ปีที่แล้ว

    wow this is excellent could i use for comercial use please? thanks in advance

  • @ZwaneMakki
    @ZwaneMakki 3 ปีที่แล้ว +1

    Great tutorial. Why do tutors never do the jump! 3 years watching these tutorials and the jump animation is always left out. IS it an insider youtube joke!

  • @idkidc1885
    @idkidc1885 3 ปีที่แล้ว +1

    pls make another tuturial making him shoot and kill enemys

  • @gorkemvids4839
    @gorkemvids4839 3 ปีที่แล้ว +1

    I thought you'll do animation movement with root motion.

  • @spacemonkey2377
    @spacemonkey2377 3 ปีที่แล้ว

    Thanks for the nice tutorial. I saw some time ago that you posted a video about Rider and how you loved it. I see in your recent content that you're back to VS. I'm at the end of my evaluation period for Rider and would love to have your opinion. Why did you switch back to VS? Thanks!

    • @Unity3dCollege
      @Unity3dCollege  3 ปีที่แล้ว +3

      Only for tutorial videos. Still love rider :)

    • @spacemonkey2377
      @spacemonkey2377 3 ปีที่แล้ว

      Awesome. Keep up the great content ;-)

  • @bouchini_yt8922
    @bouchini_yt8922 2 ปีที่แล้ว

    nice coffe cup

  • @reiydl3771
    @reiydl3771 3 ปีที่แล้ว

    When I log into Mixamo and attempt to upload the robot, it tells me it is unable to map it. I am exporting the robot file in the Art folder as an FBX file, which is how it is shown when exporting the package. Am I doing something wrong?

  • @bluestrawberry1225
    @bluestrawberry1225 3 ปีที่แล้ว

    I've been trying to limit my character animation to only keyframes, is there a way to do it using a script?

  • @MegaForrestfire
    @MegaForrestfire 3 ปีที่แล้ว

    Will there ever be a 2.5D character controller tutorial? Find out on the next..Dragon Ball Z..

  • @durgayadav3075
    @durgayadav3075 3 ปีที่แล้ว

    Aswome I. Wanted to learn it

  • @justsomeone64
    @justsomeone64 3 ปีที่แล้ว

    A lot of my code isn't turning the same colour as yours. It remains white
    Is this a problem? Because I have 3 errors 😅

  • @telmonks
    @telmonks 3 ปีที่แล้ว

    should it be _hitInfo ?

  • @sajidgame1321
    @sajidgame1321 3 ปีที่แล้ว

    Nice tutorial, I have a qeustion, for example in main menu if I changed difficulty or music volume and I will go to other scene, is will be reset all that changes what I make it, so how I will save the changes in main menu and go to other scene with that changes I made it ?

  • @hplovecraftmacncheese
    @hplovecraftmacncheese ปีที่แล้ว

    who are all those people in the credits rolling at the end? Does it take a team of 400 people to make these tutorials? lol

  • @neozoid7009
    @neozoid7009 ปีที่แล้ว

    are you using root animation :??

  • @kerbalette156
    @kerbalette156 3 ปีที่แล้ว

    Any vids on the new input system? Old one is erm old

    • @Unity3dCollege
      @Unity3dCollege  3 ปีที่แล้ว

      Not yet. Still not sure its ready for the average yet. Setup is too complicated still without some good defaults. May do one soon anyway though

    • @kerbalette156
      @kerbalette156 3 ปีที่แล้ว

      Thought it had gone to ‘verified’ state

  • @jobbydude
    @jobbydude 3 ปีที่แล้ว

    I came here for the aim part :P

  • @telmonks
    @telmonks 3 ปีที่แล้ว

    What was your camera setup?

    • @Giluby
      @Giluby 3 ปีที่แล้ว

      Did you find out ?

    • @telmonks
      @telmonks 3 ปีที่แล้ว

      @@Giluby not yet.

    • @Giluby
      @Giluby 3 ปีที่แล้ว

      @@telmonks I don't have smooth player movements either 😕

  • @tmoneygamestudio
    @tmoneygamestudio 3 ปีที่แล้ว

    did you forget to say RaycastHit where you said Physics.Raycast???

  • @systembreaker4864
    @systembreaker4864 3 ปีที่แล้ว

    I gave 1000th view

  • @mochakane9201
    @mochakane9201 3 ปีที่แล้ว

    cannot find velocities. stays at 0 although my character is moving around

    • @xXxPhipsxXx14
      @xXxPhipsxXx14 3 ปีที่แล้ว +2

      Go to Window > Animation > Animation Parameters > "+" sign > And create "VelocityX" and "VelocityZ" with Float type

  • @EmadPone
    @EmadPone 3 ปีที่แล้ว

    Can I have an email, I want to email you

  • @aaronfuraus9765
    @aaronfuraus9765 3 ปีที่แล้ว

    forget the like button???

  • @counterflipzz7084
    @counterflipzz7084 2 ปีที่แล้ว

    4:00 you cant even fucking see what is says

  • @krzysztofjarzyna4225
    @krzysztofjarzyna4225 3 ปีที่แล้ว

    First!

  • @openherewinchesterroadchan2070
    @openherewinchesterroadchan2070 ปีที่แล้ว

    зачем орать

  • @dopplegangerdavid
    @dopplegangerdavid 2 ปีที่แล้ว

    I bet this guy's like 30, but he looks 55.

  • @neozoid7009
    @neozoid7009 ปีที่แล้ว

    what a mesh up video 👎 didn't like it

  • @skizooooooooo
    @skizooooooooo 3 ปีที่แล้ว

    Awesome! Thanks a bunch :D