Rotating a Character in the Direction of Movement (Unity Tutorial)

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

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

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

    Thanks so much for watching the video. Please feel free to ask any questions in the comments. Also, please let us know what else you'd like us to cover in future videos. Thanks again 😊

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

      Is there any specific reason for using Translate instead of rigid or CharController?

  • @geoffreywade
    @geoffreywade 2 ปีที่แล้ว +5

    Thanks so much for this tutorial. I was about to plunge a knitting needle ithrough my temples and then I found this video. Simple and elegant!

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

      Glad it was useful! 😊

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

    years latter and you are a GOD SEND THANK YOU SO MUCH!!!!

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

    Hey, I just found your channel and I'm glad to see another great developer doing the best to help out the community. Keep up the good work!

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

      Great, thanks for your support 😊

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

    Thankyou very much! It's working perfectly.

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

      Great to hear, thanks 😊

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

    Absolutely beautiful tutorial worked amazingly! Thanks

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

      Brilliant, thanks for this comment 😊

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

    for anyone who wants to do it with rigidbody>>
    public float playerSpeed = 5f;
    public Rigidbody rb;
    Vector3 playerPosition;
    private void Start()
    {
    rb = GetComponent();
    }
    void Update()
    {
    playerPosition.x = Input.GetAxis("Horizontal");
    playerPosition.z = Input.GetAxis("Vertical");
    rb.MovePosition(rb.position + playerPosition * playerSpeed * Time.deltaTime);
    if (playerPosition != Vector3.zero)
    {
    transform.forward = playerPosition;
    }

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

      Thanks 👍

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

      its better to put `rb = GetComponent();` in void awake() instead of start(), also its better to put physics related stuff in void FixedUpdate()

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

      liar
      @@gulikaontop

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

      @@bendude184 usually they explain whats wrong, Id love to learn more whats wrong

  • @JorgePerez-yc6hm
    @JorgePerez-yc6hm ปีที่แล้ว +11

    This is GOLD. Thank you so much. I'm learning a lot.

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

      Great to hear 😊

  • @fernandosilvaso473
    @fernandosilvaso473 2 ปีที่แล้ว +10

    I usually don't comment yourube videos but have to say that you were marvelous. Very simple explanation and really straight to the point. Congrats, I'll probably go check the other videos and give some likes!

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

      Thanks for this comment 😊

  • @alirezafalaki-nz2wb
    @alirezafalaki-nz2wb 5 หลายเดือนก่อน

    Thank you for this practical tutorial

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

    Thank you this helped a lot.

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

      Great to hear 😊

  • @Galactiquee
    @Galactiquee 7 หลายเดือนก่อน +1

    THANKS SO MUCH❤! FINALLY AN PROPER TUTORIAL IM AN 13 (SOON 14) YESR OLD GAME DEV AND I HAVE BEEN TRYING TO FIND HELP BUT THIS HELPED ME SO MUCH TYSM!!!! ALSO YOUR GAME LOOKS SO CUTE 😢😮🎉❤❤❤❤❤

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

    Hey... thank you for this video... so clear and precise. Great job!

  • @PatitasFeroces
    @PatitasFeroces 2 หลายเดือนก่อน +2

    I simply don't understand how after reading through forums and documents, and not understanding anything, I found your video, and all my questions were answered, thank you.

    • @KetraGames
      @KetraGames  หลายเดือนก่อน +1

      This is great to hear, glad you found it useful 😊

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

    Wow you thought me to understand everything in such little time and with very efficient code. Subscribed! :D

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

    +1 follower, glad to have found your channel ♥

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

    THANK YOU SO FRICKING MUCH I WAS STUCK ON A BUG IN MY MULTIPLAYER GAME AND THIS FIXED IT OMG I LOVE U THX

  • @md.salmanahmed3903
    @md.salmanahmed3903 2 ปีที่แล้ว +1

    Plz making a video about car touch control without any asset /package scripts.

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

    Thank you so much.

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

    thanks

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

    how can you never make a typo in typing a script

  • @nv7287
    @nv7287 2 ปีที่แล้ว +6

    Really love that you build up the script one piece at a time - so it makes sense and has practical steps!! Subbed and awesome stuff!

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

      Brilliant, thank you! 😊

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

    Hello.
    I loved the video !!!
    I used this code and it works perfectly, however, when I put this code with my Jump code, my character moves extremely slowly, when I remove the rotation code, it works normally, I can't find a solution, you could help me?
    My code is the same as yours, but at the end I added:
    if (controller.isGrounded && Input.GetButton ("Jump"))
    {
    moveVector.y = jumpForce;
    }
    moveVector.y - = gravity * Time.deltaTime;
    controller.Move (moveVector * Time.deltaTime);
    Gravity is defined by a public variable.
    I tried in several ways.
    In some situations the character flies aimlessly, in others it falls into infinity and in others they just don't move, but rotate.
    How can I do it?

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

      Thanks, glad the rotation is working for you.
      Often when the character is moving really slowly it is due to multiplying by Time.deltaTime too many times. I can't tell from the code you've sent how you initially calculate your moveVector, but could it be that you have multiplied by Time.deltaTime there and are then multiplying again in controller.Move (moveVector * Time.deltaTime)?
      If you're still having trouble send over all the code and I'd be happy to take a look.
      In the coming weeks we'll be releasing videos that cover more character movement such as jumping and double jumping which may also help.

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

      @@KetraGames Hello. Thanks for the answer and the help. But I still haven't managed to resolve it.
      This is my complete code, inside the UPDATE key
      float horizontalInput = Input.GetAxis ("Horizontal") * moveSpeed;
      float verticalInput = Input.GetAxis ("Vertical") * moveSpeed;
      Vector3 moveVector = new Vector3 (horizontalInput, 0, verticalInput);
      moveVector.Normalize ();
      transform.Translate (moveVector * moveSpeed ​​* Time.deltaTime, Space.World);
      if (moveVector! = Vector3.zero)
      {
      Quaternion toRotation = Quaternion.LookRotation (moveVector, Vector3.up);
      transform.rotation = Quaternion.RotateTowards (transform.rotation, toRotation, rotateSpeed ​​* Time.deltaTime);
      }

      if (controller.isGrounded && Input.GetButton ("Jump"))
      {
      moveVector.y = jumpForce;
      }
      moveVector.y - = gravity * Time.deltaTime;
      controller.Move (moveVector * Time.deltaTime);
      In this case, the character moves VERY SLOWLY even if I increase the values ​​of the moveSpeed ​​in an absurd way.
      When I remove "Time.deltaTime" from the last line of code "controller.Move (moveVector * Time.deltaTime);", the character moves very fast and the moveSpeed ​​variable has no effect. When the character jumps, his movement is blocked, that is, he simply appears in the air and does not move there (I hope you can understand).
      When I remove the last part of the code and keep only the code of your video, the character moves and rotates perfectly, the variables have an effect on the speed of the actions, but the character does not jump (as expected).
      My "moveVector" variable is the same as your "movementDirection".
      I'm not able to find a solution, I'm not very good with unity, much less with unity 3d.
      Thank you.

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

      Hi
      I've made some changes to your script so it should be closer to what you're looking for.
      public float moveSpeed;
      public float rotateSpeed;
      public float jumpForce;
      private float gravity = 9.81f;
      private float yVelocity;
      private CharacterController controller;
      private void Start()
      {
      controller = GetComponent();
      }
      void Update()
      {
      float horizontalInput = Input.GetAxis("Horizontal");
      float verticalInput = Input.GetAxis("Vertical");
      Vector3 moveVector = new Vector3(horizontalInput, 0, verticalInput);
      moveVector.Normalize();
      if (moveVector != Vector3.zero)
      {
      Quaternion toRotation = Quaternion.LookRotation(moveVector, Vector3.up);
      transform.rotation = Quaternion.RotateTowards(transform.rotation, toRotation, rotateSpeed * Time.deltaTime);
      }
      if (controller.isGrounded)
      {
      yVelocity = 0;
      if (Input.GetButton("Jump"))
      {
      yVelocity = jumpForce;
      }
      }
      yVelocity -= gravity * Time.deltaTime;
      Vector3 velocity = moveVector * moveSpeed;
      velocity.y = yVelocity;
      controller.Move(velocity * Time.deltaTime);
      }
      It seems like the Move call was overriding the Translate call so I removed the Translate one and combined all movement into the Move call.
      The other thing that was needed was to keep track of the y velocity between frames so the gravity can change the velocity over time.
      Hope that helps

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

    I liked the video.Thanks to the author

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

      Thank you 👍😊

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

    Any solutions when a character instead rotates 90 degrees from the movement direction? EDIT: Found solution: Character rig was rotated 90 in wrong direction.

  • @nikolas276
    @nikolas276 11 หลายเดือนก่อน +1

    why is it spins my character and capsule? how can i fax it

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

    hola quiro hacer un salto en pared con tu script pero el problema es que no rota:
    void WallJumping()
    {
    if (Input.GetKeyDown(KeyCode.Space) && !TocoSuelo == false && ControlerWallChek.isTouchingFront == true)
    {
    Player.Translate(Vector3.forward * WallForward * Time.deltaTime);
    Player.Translate(Vector3.up * WallJump * Time.deltaTime);
    Player.Rotate(0, 90, 0);
    rb.AddForce(new Vector3(0, 0, WallRotation), ForceMode.Impulse);

    }
    }
    ayuda plisssssss

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

    great vid! really needed that quaternion process. Is there a way to keep an object facing in the direction of travel after the keys are let go instead of it snapping to the vertical or horizontal axises?

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

      Thanks, glad you found it useful 😊
      The script in the video should keep the object facing in the right direction after the keys are released.
      You need to check if the object is moving before applying the rotation to stop it snapping back.
      If (movementDirection != Vector3.zero)
      { ... }
      Skip to 4.40 in the video for a recap.
      Hope that helps 😊

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

      @@KetraGames Its not keeping the object facing the correct direction

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

    thanks for the tutorial it really helped a lot.

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

      Glad it was useful 😊

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

    Really nice and crisp video. Thanks! Subbed the channel :)

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

      Thanks for your support 😊

  • @rodolfoc.nascimento6301
    @rodolfoc.nascimento6301 2 ปีที่แล้ว +1

    I have seen many so Big code in the web Just tô make this function work, and then I found this Channel, a few LINE of code and boom! Done, thank you for this tutorial It help me a Lot!

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

      Great to hear. Thank you 😊

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

    That was what I needed

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

      Glad it was useful 😊

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

    Thanks!

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

    do you have a similar tutorial like this except for characters with rigidbody that use physics?

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

      Sorry, not at the moment.

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

    I ve just spent 2 hours for learn this but it s just only one line simple code..

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

    So helpful, subscribed 😇

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

      Thank you 😊

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

    Thank you, it works perfect!

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

      Thanks, great to hear 😊

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

    Extremely clear video, clear explanation, quick and with enough details.

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

      Thanks for this comment 😊

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

    Thank you so much your video helped me fix a bug (which was created by myself) for rotating the player where the player would face an opposite direction while moving on x-axis if both keys were pressed.

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

      Glad it was helpful 😊

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

    grazie mi e servito complimenti

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

    Thanks... It helped

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

      Great to hear 😊

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

    Hey I'm trying to run the code and it keeps saying "MonoBehaviour" error not found. Anyone else have this problem?

  • @TeurastajaNexus
    @TeurastajaNexus 3 หลายเดือนก่อน

    One thing to know: using transform.Translate doesn't work well with physics. For what I know, it's a forced way to move an object, so it ignores physics interaction completely. There are way better alternatives for movement, if you want to use rigidbody and have physics and collisions.

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

    Saved my sanity. Thank you.

  • @WilfordBentley
    @WilfordBentley 7 หลายเดือนก่อน

    So as someone who decided to stick with the capsule, your rotation animation script didn't work for me. It actually affected the direction my capsule turned when using the arrow keys! Up would move my capsule up, but left and right would move my character down :(
    Edit: I figured out what the problem was! Somehow I missed Space.World at line 25.

  • @Abhishek-tf8bj
    @Abhishek-tf8bj 2 ปีที่แล้ว +2

    Thanks for the rotation

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

    I''m using this for a 2.5D game and removed the vertical input and it works great. Thanks for the quick tutorial.

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

      Glad you found it useful 😊

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

    Amazing tutorial!! Thanks
    I've used transform.forward = Vector3.Slerp(transform.forward, dir, rotationSpeed * Time.fixedDeltaTime); to rotate but I'll do it with Quaternion cause I don't know much about it

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

      Thanks for this comment 😊

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

    Thanks for your video! I have a question: I only want to move along the x-axis, which means only use A and D to move (like the Mario game).
    The issue is the character always shows his back to the camera while rotating. I just want him to show his face while rotating but cannot find a way to modify the rotation as clockwise or counterclockwise. Could you please instruct me to solve this problem? Thanks

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

      Hi, that's a really good question. You could check if the rotation has gone in the wrong direction by looking at the z component of the forward vector. If it has then you could reverse the z direction. Something like this should work
      if (transform.forward.z > 0)
      {
      transform.forward = new Vector3(transform.forward.x, transform.forward.y, -transform.forward.z);
      }
      Hope this helps 😊

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

      @@KetraGames Wow! it works perfectly. I really admire your knowledge. Thanks a lot ☺

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

    thanks you

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

    excellent tutorial

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

      Thanks for this comment 😊

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

    Thank you for this video! I have been following the course of CodeMonkey about Beginner to Intermediate Game Developer, and I've found this problem about the character keeping looking to z = 0. Now I know it's because of the character gets back to that value

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

      Great to hear, thank you 😊

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

    I love it

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

    great video, I just discovered your tutorials and am doing each one, they are so easy to understand, thnk u! :)

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

      Excellent, thanks 😊

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

    Had a similar problem, different context. Great tutorial, clean code, thanks again!

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

      Thanks very much for this comment 😊

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

    Thank You.

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

    Awesome, concise but still very informative. These are the kind of videos I feel like help newer people learn without overwhelming them or killing their drive by boredom. GJ, got a sub and thumbs from me!

  • @ArribaElMole
    @ArribaElMole 5 หลายเดือนก่อน

    Thank you it worked for me using Input System!!

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

    you have a very beautiful voice!

  • @diras1127
    @diras1127 5 หลายเดือนก่อน

    Great vid, clear scripting and thanks for the distribution

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

    you are a total genius!!!!!!!!!!!!!!!!!!!!!!!!

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

    Thank you this helped a lot!!

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

      Glad it was useful 😊

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

    thank you so much for the video.
    great way to start. BUT: now my playerobject turns right, but keeps moving toward right when I press right.
    I want it just to turn with left / right. and move forward / backward only by moving up / down.
    how would I accomplish that ?
    thanks in advance

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

      Hi, if you don't want to move in the direction you're facing then you will need to separate the rotation direction and the movement direction. So set the movement direction only when pressing up/down, and change the position in this direction. Then set the rotation direction when the left/right keys are pressed and rotate towards this direction. Hope that helps 😊

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

      @@KetraGames thank you so much for taking the time to reply. I already solved the issue; made a separate rotation script and use transform-rotate with a V3 and only Haxis input. works like a charm.

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

      @@KetraGames perfect. thats exactly how I did this. thank you again

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

      hi how did you accompliss this? we have 2 different scripts but when we use "a" or "d" keys, the character slightly turns to left or right and keeps moving but we want it to rotate as long as we press the button

  • @Erick-cv1dl
    @Erick-cv1dl 3 ปีที่แล้ว +1

    hello, good video. I did the tutorial using an example humanoid, and it doesn't walk, if it rotates in the direction like in your video, but it doesn't walk

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

      Thanks.
      To make the character walk you need to add some animations. Our video on Animation Transitions may help you out - th-cam.com/video/2_Hn5ZsUIXM/w-d-xo.html

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

    I'm having a problem, it doesn't let me use the script because it says it couldn't be loaded, and it tells me to fix any compile errors and assign a valid script. When I click on the script it also tells me that there are no MonoBehaviour in the file or their names do not match the file name. Help I've been here rewriting the script, I've also tried copypasting but no luck :(

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

      Hi, it sounds like the name of the script doesn't match the name of the file. Make sure that the name of the class in the script exactly matches the name of the file in Unity. Hope that helps 😊

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

      @@KetraGames Damn that was really easy to solve haha, thank you very much

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

    You saved my life! I just got rid of the translate instruction and now I have a functioning mouse rotation option for my game using the new input system. Why is it so hard to do?

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

      Glad it was helpful 😊

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

      @@KetraGames although I have to ask. This solution makes me have to rotate my mouse around to get results. How can I transform it into a 3rd person camera where you rotate around by going left or right?

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

      @@mihaianca8602 Hi, we have a video showing how to set up a 3rd person camera that might be useful - th-cam.com/video/jiyOZbKRfaY/w-d-xo.html

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

    This video is so simple, clear & precise! Please use this code to create a video tutorial on Camera Relative Player Movement (player moving to the direction the camera is pointing). It's so hard!

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

      Great to hear 😊
      This video may help with the camera relative movement - th-cam.com/video/jiyOZbKRfaY/w-d-xo.html

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

      @@KetraGames Thanks! Will check it out. Managed to get camera relative movement to work last night, but I'm always interested in any resources I can get!
      EDIT: Wow, that video teaches other useful things regarding the TPCamera, thanks!

  • @user-nikita-kuzhel
    @user-nikita-kuzhel 2 ปีที่แล้ว +1

    Thanks a lot! You helped me)) Wish you all the best!!!

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

      Thank you! Glad it was useful 😊

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

    Amazingly simple solution for a headache of a problem, thank you!

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

      Great to hear 😊

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

    Can you tell for a rigid body which is good
    Transfor.rotation:
    transform.rotation = Quaternion.RotateTowards(*transform.rotation*, toRotation, rotationSpeed * Time.deltaTime);
    Rigidbody.MoveRotation:
    rb.MoveRotation(Quaternion.RotateTowards(rb.rotation, toRotation, rotationSpeed * Time.deltaTime));

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

      Hi, I would use MoveRotation with a Rigidbody. You'll probably also need to call this in FixedUpdate rather than Update.

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

      @@KetraGames Yeah i did exactly that! Thanks for these tutorials :)

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

    This saved me such a headache! Thank you so much!

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

      Glad it helped, thanks for your comment 😊

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

    gracias amiga muy clara tu explicacion saludo desde argentina

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

    Amazing , thank you , keep it up it helps a lot !

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

      Thanks for your support 😊

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

    Finally a tutorial that works! thanks

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

      Thanks for this comment 😊

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

    Simple and easy to understand however It doesn't work for me. I have a rigid body and capsule collider on and he turns fine but wont move, I use an extra line of code which is transform.position += directmove*speed; then he moves but doesn't rotate. Any ideas?

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

      Hi, I'm not sure what would be stopping the rotation. If you remove the rigidbody does it work?

    • @torchilicho
      @torchilicho 5 หลายเดือนก่อน

      I know it's been 2 years but i have the same problem and i need to figure out an answer

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

    I would love to see an update on that rotation that would integrate a slight tilt while rotating to add some gamefeel to the movement.

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

    Nice thank you !

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

    How can we restrict movement by mouse movemnt of an object?

  • @MG-mm7mn
    @MG-mm7mn 2 ปีที่แล้ว +1

    Thanks Millions, Mwahh.

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

    THX

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

    Thanks so much for this! Question though: How would i make it so the character doesn't snap back to a cardinal direction, like if you hold a&w to walk at a 45 degree angle and then let go, he'll stay facing that way instead of snapping back to either forward or sideways?

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

      Hi, glad you found it useful.
      The character should stay facing the direction it was moving. The key to this is to only rotate the character if it is moving. So before the rotation code you need the following or equivalent
      If (movementDirection != Vector3.zero)
      {
      }
      Hope that helps😊

    • @omar-diab-dev
      @omar-diab-dev 3 ปีที่แล้ว +1

      @@KetraGames Hello, I'm new to Unity and I found your tutorial very helpful. However, this doesn't prevent the player from snapping to the cardinal directions. The reason for this is that the player doesn't completely stop moving when we leave the buttons. The values of the horizontal and vertical movement don't snap to zero. Rather, they drop very quickly to zero which means the player is just quickly decelerating. The velocity!=0 check doesn't work. Is there another way of doing this? I'd really appreciate it.

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

      Hi, I've just retested this and can see the issue when using the keyboard. It seems fine when using a gamepad. One thing you could try to improve this is to use Input.GetAxisRaw rather than Input.GetAxis. This will snap between 0 and 1 when the key is pressed.

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

      @@KetraGames This totally worked! Thanks :)

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

      Just in case others have this solution not work for them, I found that adding if(movementDirection == Vector3.zero){ return } right before the other if statement corrected it.

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

    Hi, Amazing tutorial. Thank you!
    I was wondering if this would work with an Accelerometer object?

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

      Thanks, yes it should work with any type of input as long as you can get the direction of movement.

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

      @@KetraGames thank you so much been for this for such a long Time! 😁

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

      @@KetraGames Hi thank you it did work. I was wondering if you could help me a bit further as I want the rotation to be high like 700 but on the accelerometer, the object is shaking while in stranding still if that makes sense. how would i stop the shake rotation when it's not moving. thank you.

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

      Hi, glad you got it working. The shaking is probably due to the sensitivity of the accelerometer. You could try adding a minimum threshold to the rotation. So only rotate if the input from the accelerometer is above a certain value.

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

    TYTYTY

  • @yvesevrard2421
    @yvesevrard2421 2 หลายเดือนก่อน

    Very good, I like when the teacher is a woman, has a nice voice and gives tutorials that work.👍

    • @KetraGames
      @KetraGames  หลายเดือนก่อน

      Thank you 😊 Great to hear.

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

    Спасибо за полезные уроки

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

    Very helpful video Ketra keep up with the good education videos and helping people, keep up the good work 👍

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

      Thanks very much for your support 😊

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

    Love U!!! Thanks~

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

    This is a youtube channel that I been looking for

  • @kevaljoshi-k5y
    @kevaljoshi-k5y 6 หลายเดือนก่อน

    So many Tanks to you. I was struggling for two days and I was about to give up in a while. But, you saved me. Thanks a lot.

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

    Exactly what i needed. Thank you!!!

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

      Great to hear, thanks 😊

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

    NICEE

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

    You gotta love a girl who uses Pascal case for her variables :)

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

      ThankYouVeryMuch 😊

  • @snorelax9902
    @snorelax9902 หลายเดือนก่อน

    oh my god this was a nightmare you are awsome you get a like and sub from me you are amazing

    • @KetraGames
      @KetraGames  หลายเดือนก่อน

      Thanks for your support 😊

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

    thanks for your tutorial

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

    Excellent video!

  • @John-fg4gy
    @John-fg4gy 2 ปีที่แล้ว +1

    So helpful and super simple and straightforward explanations! Thank you!!!

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

      Great, glad it was useful 😊

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

    I love it Sir can you help to edit

  • @f.veretout
    @f.veretout ปีที่แล้ว +1

    Hey there,
    A huge thank you for sharing simple, clear and precise explanations.
    Simply magical.
    🤩🙏
    Wishing you only the best !

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

      Thanks very much for this comment 😊

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

    Great tutorial! This is what I exactly looking for. Thanks a lot!

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

      Thanks for the great comment 🙂

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

    Thanks mam i have finally found what i need. Mam how do you able to type any code so easily. I know c# in console windows. But when it comes to unity i am like 0 in my brain seems like I never heard about c#. Why is it like that with me. I sometimes feels like i will never able to type code on my own in this life. Except c# in console window.

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

      Hi, don't worry. The more you practice the easier it gets 😊

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

      @@KetraGames mam i feel like when I type the code like how you type, i mostly feel that i am memorizing it but not understanding it very well.