Item Drops (2D Unity Tutorial)

แชร์
ฝัง
  • เผยแพร่เมื่อ 31 ม.ค. 2025

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

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

    This is the video I was looking for to understand how to attach a specific item to a specific enemy. Now I get it.

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

    I really like the animation of the enemy, it's definitely a unique design. Yet another amazing tutorial!

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

      Thanks! I’m really happy with how this mech has turned out so far.

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

    This is probably the best unity tutorial ive ever watched. The definitions and thorough explanations didnt just help me do this, but i also genuinely learnt a lot. Thank you!

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

      Wow... that's high praise. Thanks for sharing, and good luck with your project!

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

    I very recently switched from Roblox to Godot so I can't actually follow along with the tutorial. But absolutely love how you're actually explaining what each line of code is doing and not just telling the viewer to do what you're doing. There aren't many tutorials like this. I almost wish I was using Unity because of how clear this tutorial is!

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

      Thanks for that! This is the best kind of encouragement. It’s so helpful to know that people are appreciating the explanations. Thanks, again!

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

      @@NightRunStudio Np! I look forward to more content from you!

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

    OKAY, i mean it, really, and im someone really looking in depth to stuff and like to have detailed and precise explanations with visuals. YOU my friend (yes we are friends now, sorry mate) have the best tutorials out there. Props on the making and like the visuals, the pace, the intonations, the pauses... really well done. (btw im a teacher, so i dont say that lightly) :)

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

      Haha! Thanks so much (my new bestie!). I so appreciate the positive, specific feedback (as a fellow teacher, I love the teacherly encouragement)! Cheers!

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

    1 year and it still helped me out alot tyyy so much

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

      Glad to hear it! Good luck with your latest project.

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

    How do I manage the quantity of the drops? For example I want 5x Item1 and 1x Item2, then how do I set that up? Also how do I make the the loot to have force of sideways too like hollow knight?

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

      The way this one is set up, you would just have to drag multiple copies of the item into the array (so drag 3 potions in if you want it to drop 3 potions). As for having the item move to the side, you would just want to change the itemDrop scripts direction. Right now it uses Vector2.up, but you would want to change that to something like: new Vector2(1,1) (which would send it up and to the right). You could also randomize the x value to something like:
      new Vector2(Random.Range(-.5f, .5f), 1) * dropForce, which would give it a random horizontal value. Hope that helps!

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

    Wow! Such an excellent tutorial! Learned a lot from this and you are great at explaining the why as you work through the code. I am trying to implement this as a system for enemies dropping health but wouldn't want them to drop every time. What would you suggest adding to the code for random drop based on a percentage? 🤔

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

      Have you ever worked with random.Range? You could create an integer called randomNum, set it using random.Range(1, 100) would get an integer out of 100, and then use an if statement so if the number is less than 50 it drops (if you want 50% chance).
      Hope that helps point you in the right direction!

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

    Great video! How would I make the item a collectable item that adds to a score counter?

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

      I don't have a video on that exact topic. That said, I have one on keeping score based on destroying enemies, which is more or less the same concept. You could pretty easily adapt this as most of the code would be the same. Let me know if you have any questions! th-cam.com/video/GXJMjWRAeMY/w-d-xo.htmlsi=Cd1MhBF9X2iihSqk

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

    Could I use this same idea to have my enemy create a tower every time another tower is destroyed in the area? Using instantiate. Ie: if total towers is less than 3, instantiate enemy tower build. Then hopefully the enemy builds the tower and moves on with his patrol.

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

      That should work. Though you'd have to make sure it's instantiating in the correct position.

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

    Graphics are nice

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

    For some reason public gameObject itemDrops doesn’t work on my game

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

      Do you have a script called itemDrops? If you don't have a script with that exact name it wont work (capitals and all).

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

    You're saving my uni work right now, but how would I make it so the each item drops in random directions?

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

      Haha! Glad to hear the videos are going to good use :)
      At the moment, the code is set up to drop the items at the precise location of the enemy. If you wanted things to drop to one side, you would need to alter that line in the instantiate code. Instead of transform.position for the location, you would need something like
      transform.position + new Vector2(1, 0)
      this would set a location 1 unit to the right of the enemy. Depending on how much randomization you want, you could try a couple of things:
      1) you roll a random number:
      int randomNumber = Random.Range(1,2);
      this would give you a random number from 1-2 (including 1 and 2).
      Now, you could have different spawns happen depending on which number comes up. For example, if you roll a 1, then you run an Instantiate code with a new Vector of 1,0, but if it rolls a 2 you instantiate with a new Vector added of -1, 0
      I hope that helps. Good luck with you course!

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

    Wow

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

    In my case the enemy dropped 2 items instead of 1.
    How to make the enemy drop 1 item, brother?
    I'am noob 😅😢

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

      How many different items did you put in your array? If you only put one item it should only drop one.
      If it’s firing twice, then I wonder if maybe you put this script on the object twice? (Sounds like it’s firing twice).

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

      as you said apparently I put this script on different objects twice?
      sorry my bad@@NightRunStudio

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

      Glad we figured it out!

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

    Woooh

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

    How to pickup the item?

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

      That really depends on what you want to do with the item. Do you already have an inventory system? If you just want the item to immediately do something (like restore health), that's pretty straightforward, but if you want to actually store the item it's pretty complex. I have a series on how to make a really simple inventory, as well as one for a more complex inventory if you are interested: th-cam.com/play/PLSR2vNOypvs6eIxvTu-rYjw2Eyw57nZrU.html&si=OkHbl4CaTK9uqqz6 and th-cam.com/video/gEG4rEz7rzU/w-d-xo.html