2D Melee in Unity Tutorial

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

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

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

    I've been working on a top down rpg game with waves of enemies, and your videos are always a nice insight on how some of these mechanics can be done and I always enjoy them!

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

      Woo! I'm happy to help! 💪

  • @yukiyukihanma
    @yukiyukihanma 10 หลายเดือนก่อน +7

    for the sword to swing in the mouse position
    mousePos = cam.ScreenToWorldPoint(Input.mousePosition);
    float angle = Mathf.Atan2(mousePos.y-transform.position.y, mousePos.x-transform.position.x) * Mathf.Rad2Deg - 90f;
    transform.localRotation = Quaternion.Euler(0, 0,angle);
    add this to playerinput

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

      this also rotates the player.

    • @sigma9.90
      @sigma9.90 3 หลายเดือนก่อน

      @@obi_ladd1405 lock z rotation on your player character

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

    You working on 2d top down series is helping me to work on some mechanics for little adventure I hopped into.

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

      Awesome! I'd love to see it when you finish it!

  • @doggo2031
    @doggo2031 11 หลายเดือนก่อน +5

    I have a question, in your demonstration, your sword swings in the direction of your mouse, when I used it, it would swing in the set direction. IS there any fix to this?

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

    Everything here is perfect, but I have a question, in your demonstration, your sword swings in the direction of your mouse, when I used it, it would swing in the set direction. Can you tell me what I'm doing wrong please?

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

      Same thing here

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

      PLEASE SOMEONE HELP HERE, IM HAVING THE SAME PROBLEM TOO!

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

    mine can only attack on one side and i dont know how to fix it

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

    Thanks for making my suggestion so quickly. Very impressive.

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

      Hey if you ask, you get it!! Thanks for watching!

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

    BRO HOW THE SWORD IS GOING WITH YOUR MOUSE POSITION

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

    Good video, but you left out the part where the sword attack changes direction with the mouse.

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

      how do you fix this?

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

    hello, when I click the mouse, the sword swings from the same place. So it doesn't shake in the direction of the mouse. What is the reason?

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

      I am having the exact same problem right now, did you manage to solve it? Or anyone?

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

      I am also having the same problem did you figure out how to fix it?

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

      same probleme here

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

      same here

    • @boa-cn1hu
      @boa-cn1hu 2 หลายเดือนก่อน

      cause its based off player rotation, which he didnt include

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

    Hi Everyone! After much hair pulling and a helpful hidden reply in here:
    In order to fix the issue of the sword only swinging once, you must change the Update() function a little.
    **after the tutorial I had it as:*
    private void Update()
    {
    if(timeUntilMelee

    • @Cato202
      @Cato202 15 วันที่ผ่านมา +1

      Hey thank you so much i was lost Also for the actual code its anim not _animator

    • @teppidd
      @teppidd 14 วันที่ผ่านมา

      @@Cato202 lol sorry I changed the variable, but I'll change it back for this comment! :)

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

    Hi, i have a problem with the sword animations when i attack it only goes halfway the animation

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

    So have you consider to to work on in game shop system,like having npc to trade with or something similar.

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

      Hell yeah! Do you mean like a Minecraft style trade?

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

      @@MuddyWolf yeah, could think of like that

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

    how can i make it so i get to next level when all enemies are killed

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

      make 2 int variables: "killcount" and "necessaryKillcount", set the first to 0 and the second to the number of enemies. Increase "killcount" by +1 on any enemy death. On update check if necessaryKillcount=killcount and if it does load the next scene

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

    Good video! I noticed the trail looks like it's still zipping back to the start position at the end of the swing. How do you prevent that?

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

      Hmm good point, the ideal solution would be to keep the sword at the end of the swing once finished, I'm sure you can set the animation to end and keep the position 🤔 I'll do a Google and write a comment if I find the solution

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

      I know this is late, but what I did to fix this was end the trail effect 1 frame before I stopped moving the sword in the animation.

  • @sigma9.90
    @sigma9.90 3 หลายเดือนก่อน

    when I set the melee speed to anything above 0 I'll be able to swing once before it stops working

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

      same

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

      just posted this comment but I'll put here.
      In order to fix the issue of the sword only swinging once, you must change the Update() function a little.
      *after the tutorial I had it as:
      private void Update()
      {
      if(timeUntilMelee

  •  ปีที่แล้ว

    I loved the video, hello friend, can you guide me with something, I'm making a combo of attacks from a 2d game but the character has 8 directions and in each direction it has an animation that I want to turn into a combo of attacks when clicking release several attacks, you can guide me. I understand that it is with events in the animations. thank you so much

  • @DragoTheSpider
    @DragoTheSpider 8 หลายเดือนก่อน +5

    for anyone who wants it to follow the cursor just attach this piece of code to a script and attach the scrip to the parent of the weapon no i dont mean the player.
    Vector3 mousePos = Input.mousePosition;
    Vector3 screenPoint = Camera.main.WorldToScreenPoint(transform.position);
    Vector2 offset = new Vector2(mousePos.x - screenPoint.x, mousePos.y - screenPoint.y);
    float angle = Mathf.Atan2(offset.y, offset.x) * Mathf.Rad2Deg;
    angle -= 90; // Adjust the angle by 90 degrees
    transform.rotation = Quaternion.Euler(0, 0, angle);

    • @sigma9.90
      @sigma9.90 3 หลายเดือนก่อน

      tried this, did not work

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

    Unfortunately since my game doesn't use the mouse I had to create a Blend Tree to properly rotate the animation depending on the direction the player is facing, like how you would with a Walking blend tree. Great video regardless, it was very helpful! :)

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

      Would you by any chance be able to explain how you accomplished this?

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

    Hi! This is actually a request from your previous bow combat tutorial but I’m posting it here to make sure you see it!
    So I really need some help, I’m struggling to make it so that instead of the bow and arrow shooting at the direction of your mouse, it shoots *depending on the arrow key you press.* So that means pressing the up arrow key would make it to shoot up, the down arrow key would make it shoot down, Left arrow key would shoot it left and etc.
    *_Of course you’d have to consider making the bow rotate before the arrow shoots too._*
    Please would you be able to help me with the code for this? I’m very new to unity and I’ve been stuck doing this for days now

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

    idk what to do mine is only swinging once and that's it, i have to restart the game but it still does the same thing

    • @Timo-gj5qq
      @Timo-gj5qq ปีที่แล้ว

      I have the same problem...

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

      @@Timo-gj5qq same here, did someone manage to work around it?

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

      same

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

      Sorry you're all experiencing this! If any of you want help fixing it feel free to jump on my discord server and create a post in the forum and I'll try help out!

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

      @@MuddyWolf why cant you tell here?

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

    this is an interesting idea but should framerate fall and you won't hit anyone

    • @sigma9.90
      @sigma9.90 3 หลายเดือนก่อน

      try putting the code to swing and detect damage in fixed update rather than update

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

    Great vid

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

    niceeeeee

  • @rafyfajarramadhan384
    @rafyfajarramadhan384 13 วันที่ผ่านมา

    11:12

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

    bruh