[#02] THIRD PERSON SHOOTER: Character Strafe Locomotion (Blend Trees + Cinemachine)

Поделиться
HTML-код
  • Опубликовано: 20 июн 2024
  • This video shows how to create a third person shooter character controller with strafing using blend trees and cinemachine.
    The blend tree is used to control the position of the player, while the cinemachine camera controls the direction of the player.
    ►Next Video: • [#03] Unity Animation ...
    ►Previous Video: • [#01] Third person cha...
    Assets used in this video:
    ► Polygon Starter Pack: assetstore.unity.com/packages...
    ► Standard Assets Characters: github.com/Unity-Technologies...
    ** Share this video **
    • [#02] THIRD PERSON SHO...
    **********************
    ** Subscribe **
    / @thekiwicoder
    ***********************
    Follow Me:
    ► / thekiwicoder
    ► / thekiwicoder
    ► / discord
    Thank you!
  • КиноКино

Комментарии • 297

  • @cozziee92
    @cozziee92 2 года назад +1

    I am just starting my unity journey after years of mobile app development and your videos have been a blessing. Please don't stop, ever. God bless you.

  • @ethanwebb2035
    @ethanwebb2035 3 года назад +9

    YOU ARE MY SAVOUR!!!, I have spent literally 3 hours watching videos trying to figure out why my character kept rotating in a circle when I strafe left and right, and no one has mentioned the world space button except you, thank you so much. 3 hours just to figure out I needed to press one button lol :)

    • @Darkknife01
      @Darkknife01 3 года назад

      I found several youtubers who when creating third person movement or controllers went over world space. Brackeys, Samyam etc. Maybe not when going over animation however

  • @wilwatts6298
    @wilwatts6298 2 года назад +1

    Thanks a lot I've watched too many videos on this subject and they NEVER mention that you have to write a script to control the animations. Keep up the good work and continue include all of the details when teaching others.

  • @killervoid6352
    @killervoid6352 3 года назад +13

    this is the only third person shooter tutorial that goes into the animator, fantastic work you earned my sub lol.

  • @user-fx3jn2cu4m
    @user-fx3jn2cu4m 2 года назад +7

    Bro this channel is such a treasure. Thanks man! The best tutorials on the internet

  • @upsurge5541
    @upsurge5541 3 года назад +1

    Man i've been trying to make my player look at the camera for 5 days now everytime i did it it caused the player to stutter alot u just fixed it for me THANK YOU BROTHER

  • @davidribeiro4781
    @davidribeiro4781 4 года назад +1

    Keep going. Great work with this. Excellent sense of what questions arise along the way and direct and educational instructions.

    • @TheKiwiCoder
      @TheKiwiCoder  4 года назад

      Thank you 🙏 More videos on their way ✌️

  • @user-nl7oq5mo4y
    @user-nl7oq5mo4y 4 года назад +3

    2 недели искал подобную реализацию движения персонажа, и вот наконец то наткнулся на твой гайд! Ты лучший!!! Hi from Russia! ;)

  • @siddharth617
    @siddharth617 2 года назад

    Really Enjoy your Tutorials! I've been struggling to grasp the concept of third-person systems...you just made them as simple as you make it sound! Great Work bro! Keep it up! : )

  • @jaehoopark8106
    @jaehoopark8106 4 года назад

    You're amazing. This is exactly what I like to learn. Please more tutorials about TPS.

  • @timithius7885
    @timithius7885 5 месяцев назад

    Exactly what I'm looking for, and Synty even! Thanks fellow Kiwi!

  • @TwistedSisler
    @TwistedSisler 3 года назад +16

    Just some input. I've found that using a Character Controller feels better than using a rigidbody and collider. You don't get caught on the environment and it feels way smoother. You just have to script your own gravity, but that is really easy to do.

    • @TheKiwiCoder
      @TheKiwiCoder  3 года назад +6

      My later video converts from a rigid body to a CC, I agree it can be a lot smoother.

    • @barkmober
      @barkmober Год назад

      @@TheKiwiCoder would it be possible for you to provide the source code?

  • @xaviergordon1343
    @xaviergordon1343 3 года назад +4

    Really In depth brilliant tutorial

  • @juanp4446
    @juanp4446 Год назад

    just fantastic, seriously these tutorials give me life bro :D

  • @DaveEsimen
    @DaveEsimen 3 года назад +1

    Amazing tutorial. So much content in such fast video. Liked and subbed. I'm gonna watch all your videos.

  • @NowWeWake
    @NowWeWake 3 года назад +2

    Hi KiwiCoder! Really enjoying this tutorial series. Thank you so much for making it. Quick note: If you don't set the X-damping to 0 in Cinemachine (which you do), the character will always strafe at a slight angle. The damping causes the camera to lag behind the player, then rotate to follow it slightly, which causes the player to turn slightly; hence the angled strafing. Man, this took me ages ;)

    • @TheKiwiCoder
      @TheKiwiCoder  3 года назад

      Ah thanks for finding that. I’ve yet to try out the 3rd person aim component as it wasn’t available when I created this video. Check here for more details:blogs.unity3d.com/2020/05/22/cinemachine-2-6-brings-you-precision-improved-workflow-and-little-bits-of-magic/

  • @game__me__me8795
    @game__me__me8795 4 года назад +1

    Your tutorials are great. Please make more videos about third person shooters.

  • @Bryan-bh7cy
    @Bryan-bh7cy 3 года назад

    dude your series is a gem

  • @marcodoesitbetter8675
    @marcodoesitbetter8675 3 года назад +1

    WoW! amazing video ! Keep it coming bro ! :D

  • @ohalohuntero
    @ohalohuntero 3 года назад

    Awesome stuff dude thanks for the video!

  • @neenaw
    @neenaw 3 года назад +1

    I too was trying to create strafing using mixamo animations. The issue is their backwards strafe animations don't blend with sideways strafing. I got to that point and remembered this exact video.

  • @WizBricks
    @WizBricks 4 года назад +1

    Thank you for this video! I've been looking for something like this on and off forever. Nobody had an answer on how to this with cinemachine.

    • @TheKiwiCoder
      @TheKiwiCoder  4 года назад +1

      I was in the same boat! That's what lead me to create this video

  • @aleqkzander
    @aleqkzander Год назад

    Good job - tutorial brought to the point :)

  • @cengizgorencom4251
    @cengizgorencom4251 3 года назад +1

    YOURE THE BEST !!! I LOVE YOU

  • @thecreativity5793
    @thecreativity5793 4 года назад +1

    Closing inspector tab for lag just saved me !

    • @TheKiwiCoder
      @TheKiwiCoder  4 года назад +1

      It's one of those gotchas of using Unity. I've found collapsing components in the inspectore will also improve performance, and only expand the component you're working on. Also collapsing sections within a component can help.

  • @thircidia7024
    @thircidia7024 2 года назад

    Great stuff man.

  • @raiskhan20
    @raiskhan20 3 года назад +2

    Liked, subscribed and also added to my library list😁

  • @billy_avila
    @billy_avila 4 года назад

    You've got great stuff keep it up

  • @durgam_sumerian7815
    @durgam_sumerian7815 3 года назад +2

    What an amazing tutorial, I hope to see a similar one for the oculus rift VR, please.

  • @hadieini4870
    @hadieini4870 4 года назад +1

    Super COOL!

  • @spideyman1909
    @spideyman1909 3 года назад +1

    BEST TUTORIAL

  • @regioninteractive6114
    @regioninteractive6114 3 года назад +1

    lookin good

  • @Mikelica69
    @Mikelica69 2 года назад

    ur a freaking saviour man!!!

  • @dkordy
    @dkordy 2 года назад

    Perfect, thank you very much. Very practical presentation. The music in the background makes the whole exhibition much more pleasant. I am very grateful to you. Essential, enjoyable exposure.The only complaint I have is - when you write a script, the letters are too small and when I expand the screen to full screen it is still very small ... somehow to enlarge while writing the code!? Otherwise, the rest is perfect ... even the voice is pleasant, professorial ... a lot of greetings and thanks for the tutorial.

  • @reinhardgercken5362
    @reinhardgercken5362 2 года назад

    Hi,
    verry helpfull video!
    I have all your infos (verstanden in german).
    I will look to your other videos (great work!)

  • @jonsimcox725
    @jonsimcox725 3 года назад

    so useful, thanks

  • @AmgedAlfakih
    @AmgedAlfakih 3 года назад +1

    thank you so much man

  • @adeveloper7184
    @adeveloper7184 4 года назад +1

    Cool! Previous shooting video has gun, i though this one gonna be about shooting machnim with all the IK and all ;) well hope those video gonna come out soon,

    • @TheKiwiCoder
      @TheKiwiCoder  4 года назад +3

      That will be coming soon! I really wanted to get this out first though, and then build the aiming system on top of this character controller.

    • @adeveloper7184
      @adeveloper7184 4 года назад

      @@TheKiwiCoder well! Coding third person shooter with all the functionality can be really painful, although there are so many visual scripting tools, but your tutorial on this is by far the unique and the easiest. Hope you cover all, like a complete game. We can wait ;) no issue. But don't make us wait like other RUclipsrs do :( best of luck with the youtube channel man! Hope to see the awesome running animations too

    • @thecreativity5793
      @thecreativity5793 4 года назад

      This would be great!

  • @workshopoleg5661
    @workshopoleg5661 3 года назад

    Awesome x2

  • @LuRybz
    @LuRybz 3 года назад

    Excelent!

  • @naishtech8132
    @naishtech8132 2 года назад +5

    2:18 - Camera Setup
    2:48 - Character Physics
    3:14 - Animation Controller
    7:06 - Character Locomotion Script
    8:26 - Character Rotation Script
    11:17 - Fine Tuning

  • @nikshepamin8570
    @nikshepamin8570 4 года назад +4

    Really Cool Tutorial. I Want My Character To Run When I Hold Shift Button Please Make A Tutorial On It. It Will Be Much Helpful For Lot Of Developers. :)

    • @dumbguy1073
      @dumbguy1073 3 года назад +3

      he already said that in 1st tutorial

  • @danthonyhill9906
    @danthonyhill9906 3 года назад +4

    Hey Kiwi long time, is there a way to use the turning animation so when rotating the camera it uses the Strafe Rapid Turn Left & Turn Right Animation rather than just stand still ??

    • @TheKiwiCoder
      @TheKiwiCoder  3 года назад +2

      Hey man, good to see you’re still tuned in! You’d need to trigger the animation when the angle distance between the camera and players forward axis raises above a threshold. I haven’t tried that but it’s a start!

    • @luanius187
      @luanius187 2 года назад

      @@TheKiwiCoder Can you do a Tutorial on it? Im a beginner.

  • @Zukomazi
    @Zukomazi 3 года назад +1

    All the animations from the GitHub have import warnings and dont work?? any tips cant even follow the tutorial now. And I was enjoying it
    :C

  • @marcodoesitbetter8675
    @marcodoesitbetter8675 3 года назад +2

    BTW, could you also make tutorial for Cinemachine sprinting animations blend tree please ?
    Was trying to mix both locomotion scripts/animations from video 1 and 2 but it doesn't look good tho :P I really like movement style from this video

  • @kieranraquel2949
    @kieranraquel2949 3 года назад +6

    Hey! TheKiwiCoder, I followed your tutorial but I am stuck where the character stays in place when I put in the character_aim script and doesn't move anywhere, any ideas? Btw, Great Tutorial.

    • @marantino1
      @marantino1 3 года назад +2

      In the inspector of the character (SM_Character_Male_01) in the Animator component turn Apply Root Motion toggle on. That fixed it for me.

  • @harharrr9810
    @harharrr9810 2 года назад

    Omg it seems so easy

  • @pietro8450
    @pietro8450 Год назад

    Nice video! Where am I can find the animations that are you using for locomotion? Thank you!

  • @quentin6687
    @quentin6687 2 года назад

    Hi ! Thanks for your tutorial ! It's really helpful !
    How can I use a mixamo character with animation of the standard assets package ?

  • @pietrodigiovanni2107
    @pietrodigiovanni2107 Год назад

    Hi! Great tutorial! Where can I find the animations pack that you are using?

  • @sshhiittoo2
    @sshhiittoo2 3 года назад +1

    I have set the value to 0 in Damping of all the fields but the camera keeps moving when I move the character, why can it be?
    Amazing job and amazing tutorials, thank you!

  • @aryangovil265
    @aryangovil265 3 года назад +8

    If anyone's character is stationary in position try changing, the rig to humanoid and ticking the green buttons present in the animation tab (note the green buttons will only be displayed when rig is changed)
    hope this helps someone

    • @aryangovil265
      @aryangovil265 3 года назад

      Thnx

    • @remcrap1139
      @remcrap1139 3 года назад

      How i dont see anything unity 2020

    • @aryangovil265
      @aryangovil265 3 года назад

      @@remcrap1139As this is a fix for 2019 version

    • @remcrap1139
      @remcrap1139 3 года назад

      @@aryangovil265 no bother i didnt attach the scripts

  • @BBoysLibya
    @BBoysLibya 2 года назад

    Really amazing tutorial really fun and easy to follow tho i ve a problem when ever my character rotates it keeps moving in a really jittery motion not as smooth as ur character is their a way i can fix this ??

  • @nastyaromanova5902
    @nastyaromanova5902 4 года назад +1

    Hey there :)
    I have an issue with this character controller and "combining" the animation rigging of the water gun from the previous video. Everything works fine, moving and all the topics that are covered in this video - until I start constraining the hands to the weapon. In game mode, my character starts floating high above the ground and in scene view I've noticed that my character has left his collider?! (the collider stands neatly on the ground...) Any idea? I noticed that all of my used animations are "read only", could this be an issue? Thanks in advance! (sorry for my english)

    • @TheKiwiCoder
      @TheKiwiCoder  4 года назад +1

      Oh someone else was having this issue, it sounded like it was something to do with exporting from blender. What character are you using?

    • @nastyaromanova5902
      @nastyaromanova5902 4 года назад +1

      @@TheKiwiCoder yep, again, many thanks. Blender import was the issue.
      EDIT for further clarification: I had to change the scaling to "FBX All" in the blender export settings and reimport the model to Unity.

  • @MystMagie
    @MystMagie 3 года назад

    How would you approach it if you wanted to have :
    - Free camera moving around the player when player is Idle
    - Player moving in direction of the Camera when player is waking/running. When player press right or left, character goes right or left (not strafing)
    - Strafe movement and zoom when aiming (right click)
    Basically thats the standard type of moment for any Third person game, like Uncharted, Assasin s Creed etc
    However i cant find any tutorial about it

    • @TheKiwiCoder
      @TheKiwiCoder  3 года назад

      Create a transition from this blend tree to a 1dimensional blend tree for the not aiming state (checkout my ai series for that blend tree). Rotate the character with the keyboard input instead of the mouse when in the not aiming state. Idle is the same as the not aiming state (I think)

  • @paulberry3359
    @paulberry3359 3 года назад +1

    Hi a bit of a silly question, as I am fairly new to Unity, but was wondering why you do not use the supplied left and backwards animations but instead just reverse the forward and right ones? Many thanks :)

    • @TheKiwiCoder
      @TheKiwiCoder  3 года назад +1

      That is a good question! I think it blended better..

    • @paulberry3359
      @paulberry3359 3 года назад

      @@TheKiwiCoder Thank you so much for replying

  • @dumitrudragomir5703
    @dumitrudragomir5703 3 года назад +14

    Hi, if you re too lazy to write here is the script for CharacterAiming
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    public class CharacterAiming : MonoBehaviour
    {
    public float turnSpeed = 15;
    Camera mainCamera;
    // Start is called before the first frame update
    void Start()
    {
    mainCamera = Camera.main;
    Cursor.visible = false;
    Cursor.lockState = CursorLockMode.Locked;
    }
    // Update is called once per frame
    void FixedUpdate()
    {
    float yawCamera = mainCamera.transform.rotation.eulerAngles.y;
    transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.Euler(0, yawCamera, 0), turnSpeed * Time.fixedDeltaTime);
    }
    }

    • @amanvahora495
      @amanvahora495 3 года назад

      5HABJ YOUUU

    • @keagancarson6371
      @keagancarson6371 3 года назад

      I guess I am pretty randomly asking but does anybody know of a good site to stream newly released tv shows online?

    • @marcusbeckham3744
      @marcusbeckham3744 3 года назад

      @Keagan Carson lately I have been using flixzone. You can find it on google :)

    • @aressantino2382
      @aressantino2382 3 года назад

      @Marcus Beckham Yup, been using FlixZone for since april myself :D

    • @keagancarson6371
      @keagancarson6371 3 года назад

      @Marcus Beckham thanks, signed up and it seems like they got a lot of movies there :) Appreciate it!

  • @drr1867
    @drr1867 3 года назад +2

    Hi - great series. I'm having problems though. My animation is very jerky - ok when not using cinemachineFreeLook but as soon as switch it on very jerky movements. Not sure what I am missing. I'm not using rigid body - I'm using character controller. Many thanks if you can advise me.

    • @TheKiwiCoder
      @TheKiwiCoder  3 года назад +1

      Jerkiness is usually caused by an update order problem. Hopefully my next video will give you some tips on how to solve this

    • @drr1867
      @drr1867 3 года назад +1

      @@TheKiwiCoder ok thanks for the quick reply - I'll press on then with the next one. Brilliant work - I notice your channel views are growing.

  • @cxv43
    @cxv43 3 года назад

    thank u

  • @regioninteractive6114
    @regioninteractive6114 3 года назад +1

    thank you very very very very very very very very very very very very much

  • @muhammadumairmumtaz6993
    @muhammadumairmumtaz6993 3 года назад +1

    i have a question , when i use this for mobile and i have button which i press the camera starts rotating towards button direction.kindly help me.

  • @andreaswenang5177
    @andreaswenang5177 3 года назад +2

    I have a question, why I can't use 2 cinemachine extensions at the same time? I want to add collision extensions cuz the camera goes through wall

    • @TheKiwiCoder
      @TheKiwiCoder  3 года назад

      It should work?

    • @andreaswenang5177
      @andreaswenang5177 3 года назад

      @@TheKiwiCoder well, it gliched like... yes the camera prevents wall collision a little bit but it still goes through wall

    • @TheKiwiCoder
      @TheKiwiCoder  3 года назад

      Andreas Wenang You could try the unity forum, the guys from cinemachine are pretty responsive there.

  • @thelostgrimm
    @thelostgrimm Год назад +1

    Awesome Video man. I'm having an issue though. I'm very new to this. everything is all set except my character won't walk. not sure how to set WASD for walking.

    • @kurviern
      @kurviern Год назад

      Hi, have you solved your problem?I can not

    • @thelostgrimm
      @thelostgrimm Год назад

      @@kurviern no man, sorry. i remember this video is kinda old and an older version of Unity. I didn't know where to look. Sadly no one felt like helping

  • @Nion193
    @Nion193 4 года назад

    great vid but i have a question its not about your video but ive used different animations and they seem to move off to an angle when there ment to go straight any idea why?

    • @TheKiwiCoder
      @TheKiwiCoder  4 года назад

      Oh man that stumped me for days! Select the animation clip, click edit, select the 'Animation' tab at the top, make sure 'Bake Into Pose' is chceked, and 'Based Upon' is set to Original. I set it for both Root Transform Rotation and Root Transform Position. You can check it in the preview window

  • @panadol34
    @panadol34 3 года назад +1

    How does the movement work? We never set up the wasd keys to move the character but somehow it just works? Also what exactly does Input.GetAxis() do in this script?

    • @TheKiwiCoder
      @TheKiwiCoder  3 года назад +2

      Magic 😂 The horizontal/vertical input axis are mapped to the wasd keys. It’s listed under input in the project preferences.

    • @panadol34
      @panadol34 3 года назад

      @@TheKiwiCoder ahh i see makes sense now

  • @yeahido9072
    @yeahido9072 3 года назад +2

    Just went through tutorial one for everything to be redone again lol

  • @ruchakshikari192
    @ruchakshikari192 4 года назад

    Very nice tutorial! I have some problem with character, when I play game mode character appear higher on the plane and drops jitter there and when I rotate the camera the character just fall through the plane? I can't find any solution for that .

    • @TheKiwiCoder
      @TheKiwiCoder  4 года назад

      Thank you! You could try snapping the character to the plane with ctrl+shift, and check the capsule collider size is what you expect. Also check 'Freeze Rotation' is checked x/y/z to on inside the RigidBody component

  • @teo2805
    @teo2805 3 года назад

    Incredible video! Wow...! One thing I'd like to do is for the player to only Strafe when pressing down a button, and otherwise, the player would just move and turn towards the sides when not pressed. Any leads? Thanks!

    • @TheKiwiCoder
      @TheKiwiCoder  3 года назад

      Hey yeah there is a line in the aiming code which rotates the player. Close that in an if block instead and check if the key is pressed

  • @5252emre
    @5252emre 3 года назад +1

    my character is floating forwards slowly. i use the charactercontroller with that i have o problems. when i use rigidbody its slide backward and if i set the mass about 5 its slide forwards

    • @TheKiwiCoder
      @TheKiwiCoder  3 года назад +1

      Hey, there are two sets of characters in the synty assets. Make sure to use the ones in the FixedScaleCharacters folder. Or if you have a custom character make sure scale is set to 1,1,1 on all game objects in the skeleton.

    • @5252emre
      @5252emre 3 года назад

      @@TheKiwiCoder thx for fast reply. i checked all scales from character mesh and rigs they are already set to 1,1,1. I using the characetr and animations from mixamo. maybe they are not combatible with animation rigging ? and my idle animation is an pistol idle, may i should take a standard idle animation ?

  • @diduward9360
    @diduward9360 Год назад

    could you add jumping or did you already add it in a future vid?

  • @elsyndur4415
    @elsyndur4415 3 года назад +3

    How do I upgrade Cinemachine? My version of it doesn't have the Camera Offset extension, and it's no longer available on the asset store.

    • @TheKiwiCoder
      @TheKiwiCoder  3 года назад +1

      Use package manager to upgrade. Everything has moved from the asset store there.

    • @elsyndur4415
      @elsyndur4415 3 года назад

      @@TheKiwiCoder Ah. Found it. Thank you.

  • @XboxPlayerPL
    @XboxPlayerPL 2 года назад

    Question. Why does my character input X and Y snaps immediately and animation transition doesn't look smooth? I need to lerp it.

  • @omarjomaa5810
    @omarjomaa5810 3 года назад +2

    great tutorial! my animations are moving to the corresponding key pressed correctly, but my character is frozen still for some reason :( any tips?

    • @TheKiwiCoder
      @TheKiwiCoder  3 года назад +1

      Thanks! It sounds like root motion is missing from your animation clips, or the root motion checkbox on the animator component is not checked. There are also some setting in the clip to specify which game is the root. Good luck!

    • @omarjomaa5810
      @omarjomaa5810 3 года назад

      @@TheKiwiCoder seems like my root motions are missing since it is checked, any alternative solution for this problem? I've been using Maya to create my animations and exporting the Skeleton + Mesh with the animations baked.

  • @theletterpurple6228
    @theletterpurple6228 3 года назад

    hiyo, im having an error where the player seem to strafe in a circle as opposed to going straight along an axis, any idea why this might be happening?

    • @perspectives2202
      @perspectives2202 Год назад

      bro change your cinemachine orbit settings to world space, that will solve the problem.

  • @kamach5242
    @kamach5242 3 года назад +1

    Hey! It's freaking good stuff! But do you know maybe how to fix: when I move my mouse quickly, camera don't go as this same speed as my mouse sensitivity, but when I move my mouse slowly it's good. Thanks in advance.

    • @TheKiwiCoder
      @TheKiwiCoder  3 года назад

      Thanks! There is a MaxSpeed setting in cinemachine, try increasing it.

    • @kamach5242
      @kamach5242 3 года назад

      @@TheKiwiCoder Ok, little fixed. In cinemachine brain on your camera, change "Update method" to "fixed update". It's not perfect but better than earlier.

  • @billy_avila
    @billy_avila 3 года назад +4

    If your Character isn't moving properly, make sure you've deleted the movement script from the previous video. The only script that should be on your character by about the 8 minute mark is Character Locomotion.

    • @aldifahluzi6998
      @aldifahluzi6998 3 года назад

      my character still doesnt move, i dont understand why:(

  • @shazboi
    @shazboi 3 года назад

    my cross hair points to the centre of the character's head when I move right, when I move left it stays offset.. how do I fix it?

  • @davidcheung9939
    @davidcheung9939 3 года назад

    Amazing video. Just wondering though, but is there a way I can stop the character from facing the camera direction when it's not moving, and have that function resume as soon as the character moves again? Kinda like in a GTA game...cheers!

    • @TheKiwiCoder
      @TheKiwiCoder  3 года назад

      Hey David! It should be pretty easy to implement that. Wrap the code inside FixedUpdate from the CharacterAiming script inside an if statement. The if statement should check if the player is moving. You can check if the player is moving by seeing if the wasd keys are down for example. That should be it! Thanks

    • @davidcheung9939
      @davidcheung9939 3 года назад

      @@TheKiwiCoder Got it and it's working. Cheers man and keep up with the amazing videos!

  • @fred1541
    @fred1541 4 месяца назад

    I am always confused by the situation when a 3d player can't rotate, but he can walk right or left or forward, back, facing to the enemy, what this term will be?
    I just find the correct term from your title, strafe motion in blend tree, thanks

  • @justinwang2882
    @justinwang2882 2 года назад

    is there any way to increase how fast or slow the character move?

  • @danielconde001
    @danielconde001 3 года назад +1

    im missing the Cinemachine Camera Offset extension. What could be the problem here?

    • @SamuelPenning
      @SamuelPenning 3 года назад

      Look under "Add Extension" in the bottom of the CinemachineFreeLook component. It's at 14:43 in the video. Took me a while to figure it out, too.

  • @haithammahmoud6825
    @haithammahmoud6825 4 года назад +1

    sry for ask but can u add camera collision .. so when there's something between player and camera

    • @TheKiwiCoder
      @TheKiwiCoder  4 года назад +1

      Checkout this page. docs.unity3d.com/Packages/com.unity.cinemachine@2.1/api/Cinemachine.CinemachineCollider.html

    • @creasu124
      @creasu124 4 года назад +1

      I think this easily can be done with a raycast starting from the head + a little distance that it’s not going inside the head to the position of the camera when hitting nothing and if it hit’s something the hit position is the new camera position

  • @appleseeds2843
    @appleseeds2843 3 года назад +1

    @TheKiwiCoder Im having some trouble with my character movement. I can move the camera but I cant move the charater.
    Any advice?

    • @appleseeds2843
      @appleseeds2843 3 года назад +1

      And Do you need a controller for this to work??

    • @TheKiwiCoder
      @TheKiwiCoder  3 года назад

      No this video uses a rigid body.

  • @branislavzivanovic4775
    @branislavzivanovic4775 3 года назад +1

    Are you using the old input system or the new input system?

  • @SamuelArmer
    @SamuelArmer 2 года назад

    Help!
    All my motion configuration settings are correct but when I move the red dot to top right the character runs in a circle
    Help please :)
    And when I change the Accel Time and Decel Time to 0.02 the camera just snaps to where it need to be it's not smooth

  • @sp0ngebob561
    @sp0ngebob561 3 года назад +2

    Excuse me in your next tutorials do u mind increasing your font size
    Nice video, I learnt a lot.

    • @TheKiwiCoder
      @TheKiwiCoder  3 года назад

      Thanks for the feedback, sure thing!

    • @sp0ngebob561
      @sp0ngebob561 3 года назад

      @@TheKiwiCoder thanks for the response my man

  • @arnoldswarz9692
    @arnoldswarz9692 4 года назад

    After creating CharacterLocomotion script i got errorCS0246.. The type or namespace name 'animator' could not be found (are you missing a using directive or an assembly reference?)
    What is that ?? :(

    • @TheKiwiCoder
      @TheKiwiCoder  4 года назад

      Hey, double check the 'using' statements at the top of the file. Also checkout this page:
      support.unity3d.com/hc/en-us/articles/206116726-What-is-CS0246-

  • @hungrygrimalkin5610
    @hungrygrimalkin5610 3 года назад

    Isn't Character Controller better for this instead of a rigidbody? Maybe its just me but I get anxious around rigidbodies since Skyrim.

    • @TheKiwiCoder
      @TheKiwiCoder  3 года назад +1

      Haha! Yeah character controller is more flexible, rigid body is good for physics characters, like vehicles and drones and stuff.

  • @drr1867
    @drr1867 4 года назад

    Thanks for the tutorial. I'm having a problem getting a Mixamo character to work with animations - I'm copying rig from other character - my Mixamo T-Pose but I'm getting rig configuration mis-matches transform hierarchy does not match. Does this mean I cant use different characters with these animations? Many thanks

    • @TheKiwiCoder
      @TheKiwiCoder  4 года назад

      Hi, your rig and character need to be compatible with each other. If you have a character without a rig, it’s best to rig it in a tool like blender.

    • @drr1867
      @drr1867 4 года назад +1

      @@TheKiwiCoder hi thanks for getting back. My character and rig are from Mixamo and humanoid but they don't match up with the animations you are using from standard assets. Is there a way of using different animations from mechanim and the ones you are using with rigged characters from Mixamo? Or how can I use a different more realistic character with your tutorials? Many thanks

    • @TheKiwiCoder
      @TheKiwiCoder  4 года назад

      From my understanding, humanoid animation clips can be used on any humanoid character. Is your character humanoid?

    • @drr1867
      @drr1867 4 года назад +1

      @@TheKiwiCoder Hi thanks for getting back. Yes, set to humanoid and from mixamo. I set the animations to copy from another avatar and chose my character - that's where it went wrong. I thought this was the process for the animations to work without deforming - it's all a bit confusing. I hope you will be able to look at this for us at some point - pleeeeease? Thanks again.

  • @fongaming101
    @fongaming101 5 месяцев назад

    my reticle is off when i move to the left due to the animation. cant figure it out but trying..

  • @itsworm4247
    @itsworm4247 7 месяцев назад

    How do we get the feet to move in when the player turns in place?

  • @lemax2980
    @lemax2980 4 года назад +1

    Can you please teach us about procedural animations? Like movement of spider legs on any terrain..would be deeply obliged if you could teach us🙃

    • @TheKiwiCoder
      @TheKiwiCoder  4 года назад +4

      Hey great suggestion, I'd like to know how to do that also, so I'll see what I can do! The new Unity Animation rigging package sounds like it might be useful for this type of animation.

    • @lemax2980
      @lemax2980 4 года назад

      I've setup the IK but still confused about the code.😅

    • @lemax2980
      @lemax2980 4 года назад

      @@TheKiwiCoder yes sir..there are mutiple ways to approach this.we can set this up using any IK tool and some cool code to shift the position of target point attached to each legs and move them accordingly relative to the main centre of mass.
      It is a super cool technique and has many applications.I am interested and excited to learn from you🙌🤗

    • @TheKiwiCoder
      @TheKiwiCoder  4 года назад +1

      @@lemax2980 Cool, thanks for the head start haha. This video is really great and shows the power of procedural animation. Definitely worth checking out! ruclips.net/video/KLjTU0yKS00/видео.html

  • @SHOST01
    @SHOST01 3 года назад +4

    When you strafe from left to right quickly the character will snap to the next animation. Is there any way to make this transition smoother?

    • @TheKiwiCoder
      @TheKiwiCoder  3 года назад +1

      Good point. I think what is happening is the input is snapping from left to right as the direction is changed.

    • @SHOST01
      @SHOST01 3 года назад +1

      Do you know of any way to make it smoothly go into the next animation when the direction is changed instead of snapping to it?

    • @TheKiwiCoder
      @TheKiwiCoder  3 года назад +3

      This page has some more details: answers.unity.com/questions/341962/smooth-transition-for-getaxis-when-pressing-opposi.html

    • @SHOST01
      @SHOST01 3 года назад +3

      @@TheKiwiCoder You. Are. AWESOME! This helped fix it. I have been looking everywhere for some way to fix this. Thank you!

    • @raveheart58
      @raveheart58 3 года назад +2

      Jade Clayton 🙌

  • @brandongrill5132
    @brandongrill5132 3 года назад

    Why are my camera and mouse inputs inverted? Ie. When i look up th camera looks down.. *all the code is the exact same so idk if it has something to do with the input variables or what?

    • @ethanjones5623
      @ethanjones5623 3 года назад

      Check the invert properties on the cinemachine camera, almost always have to switch them.

  • @nobody971
    @nobody971 3 года назад +5

    Hey! Great tutorials. Though, I followed this very slowly and somehow got an error for the CharacterAiming script. It said the "float yawCamera = mainCamera.transform.rotation.eulerAngles.y;
    " line had an issue. The script is assigned to my character model btw!
    Here is the error:
    NullReferenceException: Object reference not set to an instance of an object
    CharacterAiming.FixedUpdate () (at Assets/Scripts/CharacterAiming.cs:20)
    Thanks for the series of tutorials, it helps a lot with learning animation in Unity!

    • @nobody971
      @nobody971 3 года назад +5

      I fixed the issue... I am not entirely sure of the issue itself, and why in the video it worked (and not for myself). My theory is the update I may have been using might've rejected the code. Anyways, in the start(), DONT repeat mainCamera = Camera.main... There is no point. It essentially detached the camera, so it's counterproductive.
      My CharacterAiming script! ALSO, I have made the camera public, so don't forget to link in the inspector...
      hatebin.com/gndzdljapq

    • @xxasafxx1
      @xxasafxx1 3 года назад +1

      @@nobody971 HEY MEN I HAVE SAME ISSUE ... AND MY PLAYER MOVE IN PLACE . YOU HAVE IDIA HOW TO FIX ?

    • @adamgiuffrida3972
      @adamgiuffrida3972 3 года назад

      @Christian Alp dude I was losing my mind thank the lord he had the answer lmao

    • @markegan2570
      @markegan2570 2 года назад

      @@nobody971 Thanx! Works

    • @phantom5229
      @phantom5229 Год назад +1

      @@nobody971 👍

  • @faraznawazsandhu
    @faraznawazsandhu Год назад

    vector 2 doesn't contain a definition for GetAxis , facing this error while writting the scrip.

  • @noahfarnsworth2610
    @noahfarnsworth2610 3 года назад

    I can’t move forward with how u set it up? Only diagonal. Help?

  • @mestesso2174
    @mestesso2174 2 года назад

    in cinemachine 2.1.10 camera offset addon is not more avaialable... how to solve??

  • @user-go1ch5qk1q
    @user-go1ch5qk1q 4 года назад +2

    Hey Thank u for this Tutorial it´s really awesome!
    I just have a problem with the aiming script somehow the camera doeast stay behind the player and the rotation of him stays in place but i can orbit around him, and the movement script is also working fine.
    my console is saying:
    NullReferenceException: Object reference not set to an instance of an object
    CharactrerAiming.FixedUpdate () (at Assets/CharactrerAiming.cs:27)
    maybe u have a clue whats wrong i did everything in the same order as you did, but didnt found any obvius errors.
    Thank U for the awesome work!

    • @TheKiwiCoder
      @TheKiwiCoder  4 года назад +1

      Thanks!
      To resolve the camera not staying behind the player, set the binding mode property on the cinemachine free look camera to world space.
      And for the console error... make sure the camera object is not null by either assigning it in the inspector if it's public, or using Camera.main instead.
      Hope that helps!

    • @MattGibbard
      @MattGibbard 4 года назад

      I'm getting the same thing too.

    • @MattGibbard
      @MattGibbard 4 года назад

      Looks like the problem relates to this line here: float yawCamera = mainCamera.transform.rotation.eulerAngles.y;

    • @MattGibbard
      @MattGibbard 4 года назад +2

      Ok, I've found a fix. Change the "Camera mainCamera;" to "public Camera mainCamera;" and make sure you drop your camera into the public field on the inspector window when you have the player selected. You then need to comment out the "mainCamera = Camera.main;" by add two backslashes "//" before it like this "mainCamera = Camera.main;".

    • @user-go1ch5qk1q
      @user-go1ch5qk1q 4 года назад +1

      Thanks a lot ! this was the problem just had to make the camera public and assigne it in the inspector :)

  • @juansalvatore7450
    @juansalvatore7450 2 года назад +1

    For it to work in the current Unity version (2021.3.0f1) I had to declare the method FixedUpdate instead of camel case (fixedUpdate) like in the video