BEST Top Down 8 Directional Animation - Unity 2D

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

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

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

    Cool to know about these blend trees. Last time I messed around with the animator I made a lot of transitions to different animations manually

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

      Yeah when I found out about blend trees my whole life changed! It's nice to group things together with them :-) keeps it much tidier!
      I've just planned the animations for my future platformer series which uses all transitions instead of blend trees, so it can work well for simple games!

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

    Yayy, another vid

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

    really nice tutorial, this helped me to understand how blend trees work and now I will use this in my own project. thank you so much!!

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

      You’re welcome!! I’m so glad it helped 😊 I love using blend trees!

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

    Your voice is so soothing, Love the tutorials!

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

      Glad you enjoy :-) Thank you!!

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

    The only thing this is really showing me, is how far away I am, from typing something in VS and go back into unity... and its just working as I want it to...

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

    when pressing for diagonal movement does your diagonal idle movements show because Unity seems to register the last button released and snap them to either left right up or down

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

      I had this problem too! It is possible to get it to end diagonally, but it’s due to it reading either the up or side like 0.01% more than the other, so it isn’t a perfect diagonal input.
      To get it to stay diagonal, you could make the threshold for changing directions higher than 0 so that it stores the last move before exactly 0 for both x and y.
      I tried to find an easy fix for this video, but couldn’t find one without it getting more complicated, so left it out!
      Here’s a thread I found on other peoples solutions too: discussions.unity.com/t/8-way-movement-diagonal-idle-issues/172804
      It seems to work better with a controller since the input is more precise! But keyboard can be harder to get exact.
      Good luck!! I’ll let you know if I find another fix in the future!

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

      I need this fix also.. even chat gpt didn't help :(

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

      @@dexi7205 did you get it to work?

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

      I found a solution. It's not great, but it's okay.
      /////////////////////////////////////////////////////////////////////////////////////
      public float speed;
      private bool isMoving = false;
      private Rigidbody2D rb;
      private Animator animator;
      private void Awake()
      {
      rb = GetComponent();
      animator = GetComponent();
      }
      private void FixedUpdate()
      {
      Movement();
      }
      private void Movement()
      {
      float moveX = Input.GetAxis("Horizontal");
      float moveY = Input.GetAxis("Vertical");
      Vector2 move_dir = new Vector2(moveX, moveY).normalized;
      if (!isMoving)
      {
      StartCoroutine(CheckIdle());
      rb.velocity = Vector2.zero;
      }
      else
      {
      rb.velocity = move_dir * speed;
      }
      }
      private IEnumerator CheckIdle()
      {
      isMoving = true;
      yield return new WaitForSeconds(0.1f);
      float moveX = Input.GetAxis("Horizontal");
      float moveY = Input.GetAxis("Vertical");
      if (Mathf.Abs(moveX) > 0 || Mathf.Abs(moveY) > 0)
      {
      animator.SetFloat("x", moveX);
      animator.SetFloat("y", moveY);
      animator.SetBool("is_moving", isMoving);
      StartCoroutine(CheckIdle());
      }
      else
      {
      isMoving = false;
      animator.SetBool("is_moving", isMoving);
      }
      }
      /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

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

      @@GameCodeLibrary
      Is this what you mean?
      Vector2 currentMoveInput = move.ReadValue();
      if ((currentMoveInput.x == 0 && currentMoveInput.y != 0 || currentMoveInput.x != 0 && currentMoveInput.y == 0) && (direction.x != 0 && direction.y != 0))
      {
      lastMoveDirection = direction;
      }
      // Create a direction vector based on the input
      direction = move.ReadValue();

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

    I got an error thats quote "Assets\PlayerMovment.cs(56,45): error CS1061: 'Vector2' does not contain a definition for 'Magnitude' and no accessible extension method 'Magnitude' accepting a first argument of type 'Vector2' could be found (are you missing a using directive or an assembly reference?)" and i dont know how to fix it. I have no coding experience and i put the anim.SetFloat("MoveMagnitude",input.Magnitude); like you did in your video but its giving me this error.

    • @GameCodeLibrary
      @GameCodeLibrary  7 หลายเดือนก่อน +3

      Need to be a lowercase M on magnitude
      Code is case sensitive! :-)

  • @Garlic2.0
    @Garlic2.0 ปีที่แล้ว +1

    Very good at simplifying things ,keepup 👍

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

      That's the goal! Sweet and simple - thanks so much!

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

    didnt work for me it keeps the animation state play on my idle down animation instead of every input direction
    edit: nvm i forgot to set the blend types to last move

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

    I got this error and I dont know how to fix it
    NullReferenceException: Object reference not set to an instance of an object
    Move.FixedUpdate () (at Assets/Scripts/Move.cs:34)

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

      If you double click on your error it takes you to the line with the problem!
      Line 34 in our script is the rigidbody.
      Make sure you select your player and drag the rigidbody into the rigidbody slot.
      Or - in your Start function do:
      rb = GetComponent();

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

      @@GameCodeLibrary thanks it works but now Im getting 999+ warnings saying MoveX, MoveY, LastMoveX, LastMoveY and MoveMagnitude does not exist

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

      Already fixed it thanks

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

    Nice Tutorial

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

    nice tutor but it took 3 days ytb to notify me that u just posted a new clip 😂

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

      Haha oh no! Maybe I should make a community post each time I post a new vid... but I don't want to be annoying 🤔

  • @Kira-wu4yp
    @Kira-wu4yp ปีที่แล้ว

    Thx!

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

    2d Ai and 3d