Flexible LOOT SYSTEM in Unity with Random Drop Rates

  Рет қаралды 46,454

BMo

BMo

Күн бұрын

Пікірлер: 91
@mandamoon9149
@mandamoon9149 2 жыл бұрын
A book, a fish, and a gem walk into a bar….. and Bmo’s at it again with that good content
@arturoescobar4226
@arturoescobar4226 2 жыл бұрын
Soo useful, I will definitely going to use this for my next school proyect, thank you so much and keep up your amazing videos. Really helps me and other beginners a lot.
@sn0man
@sn0man 2 жыл бұрын
Great lesson here. Very clearly shows the fundamental to getting an RNG loot system in place.
@nikaman9539
@nikaman9539 2 жыл бұрын
Im so lucky that i picked up Unity again after years during the time u have started uploading content mate
@SelaMalka
@SelaMalka Жыл бұрын
Very nice! And now I'm gonna steal it. Thank you!
@seaderwerks3046
@seaderwerks3046 Жыл бұрын
I've watched several of your videos. This is the one that got me to subscribe. Thank you for this. Simple, effective and easily modifiable.
@spd9190
@spd9190 Жыл бұрын
Fantastic video. I saw a few comments below asking how to differentiate the items since they all drop from the same prefab. For example in my game I want the items to have a different effects when the player picks them up. I added this line of code to your script under the InstantiateLoot function in the LootBag script to add a tag to the prefab depending on what the lootName is. From there you can just add an onCollision function in the player script to react to the tagged item. Hope this helps public void InstantiateLoot(Vector3 spawnPosition) { Loot droppedItem = GetDroppedItem(); if(droppedItem != null) { GameObject lootGameObject = Instantiate(droppedItemPrefab, spawnPosition, Quaternion.identity); lootGameObject.GetComponent().sprite = droppedItem.lootSprite; //assign tag function if(droppedItem.lootName is "Shield") { lootGameObject.tag = "Shield"; } } }
@Філіпс-й4ш
@Філіпс-й4ш 2 жыл бұрын
At right place, at right time! Thx for tutorial)
@xyphelon
@xyphelon Жыл бұрын
Epic Video, Just found your channel, trying to figure out some stuff, magically it appeared. Great Content!!!! Hope your channel grows
@FullMe7alJacke7
@FullMe7alJacke7 2 жыл бұрын
Underrated channel! Keep up the excellent content
@happyghoststudios4237
@happyghoststudios4237 2 жыл бұрын
Great video! Very helpful! I am very enthusiastic!!!!
@Jona69
@Jona69 2 жыл бұрын
Hey man. I just found your channel and I love you tutorial style. Very helpful!
@mitchellknirnchild8285
@mitchellknirnchild8285 2 жыл бұрын
Hey, your tutorials are amazing and you deserve millions of subs.... Loving watching and learning from you so far!!
@BMoDev
@BMoDev 2 жыл бұрын
Appreciate ya
@sr_ber1816
@sr_ber1816 Жыл бұрын
@@BMoDev hello in your video Easy Ammo & Reloading System in Unity i have a problem in end first code you put weapon.Reload but you dont share something with weapon and console drop me error i dont have idea how cant i fix this pls help
@CokeVoAYCE
@CokeVoAYCE Жыл бұрын
thanks. easy, simple, complete and concise.
@thenubblet3925
@thenubblet3925 2 жыл бұрын
this is a really cool way to do loot your video's often show me better ways do do simple process and systems, all your systems are easily expandable to suit more complicated games if you love rng and wanted to a random amount of loot to drop you could put the whole of GetDroppedItem inside a for loop and roll the limiting INT to decide how many times it roles for loot
@BMoDev
@BMoDev 2 жыл бұрын
Great idea, and thanks for that!
@Kylenavyify
@Kylenavyify 2 жыл бұрын
You, sir, have earned my sub and like.
@HrSkully
@HrSkully Жыл бұрын
Very Helpfull and good Tutorial!!! Thanks a lot! It is exact what i needed
@JERSCOM
@JERSCOM Жыл бұрын
If you want to do this in a 3d game, like me that I'm currently doing an rpg, all you have to do is change the sprite variable in Loot for GameObject
@Raydamick
@Raydamick 2 жыл бұрын
hey I was just wondering how to differentiate the items from each other, since they all come from 1 prefab
@viktorpavlovskiy2120
@viktorpavlovskiy2120 Жыл бұрын
how can I adapt this for 3D?
@Whopen
@Whopen Ай бұрын
it says list doesnt have a definition for lootsprite what do i do
@mayesawidiandita1434
@mayesawidiandita1434 Жыл бұрын
How do you write a function to retrieve loot items?
@toddietubby7450
@toddietubby7450 Жыл бұрын
for some reason when the loot scriptable objects have the same dropChance value only one of them ever spawns and cancels out the other
@pablogoni6267
@pablogoni6267 Жыл бұрын
is there a way that instead of using sprites use a gameobject?
@Spider_In_The_Ditch
@Spider_In_The_Ditch 11 ай бұрын
That last line of code obliterated my game for some reason. Is there a way to use a game object instead of a sprite. I fell asleep last night thinking about going how I may take your use of a number generated system and apply it to my game. Thankfully I only had two drops, so what I did was took the way you did the number generator added it to my enemy controller script in the section where if the enemy's health gets to zero, they die. So, I added an if statement (which states) if a number from less than 10 is chosen than one item drops (I used an enemy drop sequence that had worked for me prior) and if a random number greater than 91 is chosen than the other item drops. Even if your tutorial wasn't completely compatible with my game. You still taught me some of the building blocks which allowed me to add a feature I have been wanting to add to my game. Thanks!
@totallyoffgrid3008
@totallyoffgrid3008 Ай бұрын
I am really struggling with this….Lol. If I have a boss, and I want a particular piece of armour to drop from only that boss…. Do I just attach the script to the sprite?
@emanueltejadacoste2250
@emanueltejadacoste2250 2 жыл бұрын
Nice video, you always bring useful tips and features, for some reason is kind of low quality, 360p max , not a big deal but felt kind of empty
@BMoDev
@BMoDev 2 жыл бұрын
Thanks appreciate that, it looks like it goes to 1080p now, you may have caught it early enough when it was still processing
@emanueltejadacoste2250
@emanueltejadacoste2250 2 жыл бұрын
@@BMoDev Oh yea, nice! I'm sorry I said bad quality instead of low resolution or some XD
@lunaris356
@lunaris356 2 жыл бұрын
Hey BMo! So I'm trying to figure out a way to return the dropped item, while keeping the ability to drop multiple items at the same time? Help would be appreciated, love the video so far!
@lunaris356
@lunaris356 2 жыл бұрын
@Nevu Abo No I have not sadly, I'm pretty inexperienced and haven't had much time to test it out being busy with school.
@McAVGamer
@McAVGamer 2 жыл бұрын
Same, if you got solution please update.
@mmmargh4743
@mmmargh4743 Жыл бұрын
Can you be more clear please? I'm not sure to understand your issue
@darkbatu
@darkbatu Жыл бұрын
how can works for 3d objects?
@feelmacan
@feelmacan Жыл бұрын
I checked that the code is running well. By the way, how can I modify the code to randomly drop prefabs instead of sprite files?
@darkbatu
@darkbatu Жыл бұрын
same problem here haha
@toddietubby7450
@toddietubby7450 Жыл бұрын
i'm a real noobie so take my advice with caution, but the way i did it was to add a public gameobject prefab reference to the scriptable object, then instead of instantiating DroppedItemPrefab, i spawn the droppedItem.prefab since the dropped item variable IS the scriptable object you can access the prefab from there;
@blenderinc.4402
@blenderinc.4402 2 ай бұрын
Why arent there 2xn lists for the unity editor? or is there a way to get one?
@DijbanCyclone
@DijbanCyclone 2 жыл бұрын
i would love a tutorial for an shop system like enter the gungeon or neon abyss
@AceAmStiel
@AceAmStiel Жыл бұрын
isnt the dropchance of a low dropchance item way worse? if i have 100 items in the lootlist i first need to hit lets say a 2% dropchance and then need to roll the item in the lootlist again? so i roll twice for one item?
@MeloDev-ll9yi
@MeloDev-ll9yi 5 ай бұрын
That's really cool, but I think you shoud make a random throw the sum of chances. And in this case if u want to make empty drop simply make a null field.❤❤
@Su-qm6ge
@Su-qm6ge Жыл бұрын
I really love your code but I stuck on drop more than one item like one enemy died is drop 2 gold ore and one gold bar can u please help me to make it or explain me to do it Thank again for your wonderful code. :)
@ThePoePoee
@ThePoePoee Жыл бұрын
how do i incorporate this with the inventory system
@KRAXi-
@KRAXi- Жыл бұрын
Hey man im loving theses tutorials. I have one question in the how to get an enemy to chase you in unity tutorial i have an issue with the public static event ActionOnEnemyKilled; code it pops up an error saying Assets\Enemy.cs(7,25): error CS0246: The type or namespace name 'Action' could not be found (are you missing a using directive or an assembly reference?) im pretty new to all of this and i have no idea how to fix this. i cant progress threw the tutorials becasue im stuck ont this part. However theses are awesome and simple thank you! keep it up
@NgocHo98
@NgocHo98 2 жыл бұрын
Thank you Sir Can you make a video how to make a Quest system ?
@maheshcharyindrakanti8544
@maheshcharyindrakanti8544 2 жыл бұрын
Ty I got my first divine because of you
@BMoDev
@BMoDev 2 жыл бұрын
Idk what that means but I'm glad
@GamingGables
@GamingGables 2 жыл бұрын
Awesome video! I had a question on using this for 3D game objects. Instead of using "GetComponent().sprite" could I use GetComponent()? Not sure what the equivalent would be when working in 3D. Thank you for your excellent content!
@heyuparry5152
@heyuparry5152 2 жыл бұрын
did you solve the problem?
@TheJakeblake
@TheJakeblake Жыл бұрын
That would not work since so would only be getting the Mesh with out textures, that get Component is so that the image in sprite render gets automatically serialized and so it can be shown in game, you don't have to use that in this case, you could just make a gameObject variable and manually serialize that on the inspector
@Batak-dg4gc
@Batak-dg4gc Жыл бұрын
First thing first bro thanks for the vid but i have a question.when i drag my sprites the list not accepting it can you help me please?
@WeirdGoat
@WeirdGoat Жыл бұрын
The only thing I found missing is putting items in a pool, just in case you have lots off loot on the screen, add a switch, then you can easily use this in your other projects
@davidabris
@davidabris Жыл бұрын
Hello I have a question: Is it safe to use public for lootList? Can't it modified by a player?
@neffthepanda
@neffthepanda Жыл бұрын
trying to integrate this into Coding With Unity's inventory system tutorial but having a really hard time
@neffthepanda
@neffthepanda Жыл бұрын
I actually figured it out. With that tutorial you already have scriptable object called ItemObject. You can just use that data instead of creating the loot script. Then add the ItemObjects into the lootbag and instantiate them when the enemy health is >= 0. Still used the drop chance too.
@renwilliams59
@renwilliams59 Жыл бұрын
For those wanting to do a 3D object instead of a Sprite, it's SUPER easy: Delete the two references to the sprite (the public variable in Loot, and the lootGameObject...sprite = droppedItem.lootSprite in LootBag). Create the item you want dropped in the world as you normally would. So drag a 3D cube to the screen if you want to drop a cube. Fix it up however you'd like and create a prefab out of it (i.e. Drag it into a folder in your assets) Whatever Object has the Loot Bag Script attached to it, change the Dropped Item Prefab to that new prefab you just made (so don't use LootPrefab, it was just an example item). And that's it! Since nothing is referencing a sprite, it'll just drop the whole object.
@AceAmStiel
@AceAmStiel Жыл бұрын
wouldnt that just allways drop the new prefab you created?
@tienatnguyen7139
@tienatnguyen7139 10 ай бұрын
My gem always move when it was created and not stop like you ?? how can I fix this
@ECAKJ
@ECAKJ 8 ай бұрын
up the mass and friction in rigidbody
@cheetah7887
@cheetah7887 2 жыл бұрын
hey bmo how can i pick up the items that dropped like an ammo box
@voltex9157
@voltex9157 8 ай бұрын
thx a lot, but how i use them? like add script to the loot so i use them
@MarstonBoii
@MarstonBoii 2 жыл бұрын
Hey BMo! Is there a chance to get a tutorial on Quick Time Events in Unity, please?
@itsspider6156
@itsspider6156 Жыл бұрын
my items dont stop moving, why?
@jackselhpdepr2892
@jackselhpdepr2892 8 ай бұрын
Same if i found a solution i will let you know
@jackselhpdepr2892
@jackselhpdepr2892 8 ай бұрын
Hey i found it, for me when i put 4 on the Linear drag (on the Rigidbody2D) it solved my problem, you can try adjusting that and see whats work for you
@MGameDev22
@MGameDev22 Жыл бұрын
Can i use this for a 3d game?
@DasShiro89
@DasShiro89 5 ай бұрын
Hi i love ur tutorial and i hope u still read this i have some issue with the multiple item drop. using System.Collections; using System.Collections.Generic; using UnityEngine; public class LootBag : MonoBehaviour { public GameObject droppedItemPrefab; public List lootList = new List(); List GetDroppedItems() { int randomNumber = Random.Range(1, 101); List possibleItems = new List(); foreach (Loot item in lootList) { if(randomNumber 0) { Loot droppedItem = possibleItems[Random.Range(0, possibleItems.Count)]; return droppedItem;
@zote1
@zote1 4 ай бұрын
here is the fixed code lol using System.Collections; using System.Collections.Generic; using UnityEngine; public class LootBag : MonoBehaviour { public GameObject droppedItemPrefab; public List lootList = new List(); List GetDroppedItems() { int randomNumber = Random.Range(1, 101); List possibleItems = new List(); foreach (Loot item in lootList) { if(randomNumber 0) { return possibleItems; // Return the list of possible items } return null; } public void InstantiateLoot(Vector3 spawnPosition) { List droppedItems = GetDroppedItems(); if(droppedItems != null && droppedItems.Count > 0) { Loot selectedLoot = droppedItems[Random.Range(0, droppedItems.Count)]; GameObject lootGameObject = Instantiate(droppedItemPrefab, spawnPosition, Quaternion.identity); lootGameObject.GetComponent().sprite = selectedLoot.lootSprite; float dropForce = 300f; Vector2 dropDirection = new Vector2(Random.Range(-1f, 1f), Random.Range(-1f, 1f)); lootGameObject.GetComponent().AddForce(dropDirection * dropForce, ForceMode2D.Impulse); } } }
@TheLunarah
@TheLunarah Жыл бұрын
Thank you
@jaydenvogt1286
@jaydenvogt1286 2 жыл бұрын
Great lassen i love und top down shooter tuts .❤ Can u please do next time how to make a high score or Player health or a enemy spawner
@boboyedaniel9660
@boboyedaniel9660 2 жыл бұрын
As always, everything is super. Waiting for new cheats from your side
@dariuszwesierski1928
@dariuszwesierski1928 Жыл бұрын
Like always. not working in my engine xD even GPT says code is writed good. but when i have other system like items, inventory, equipment, then something must go wrong ;/ ehh
@tomkc516
@tomkc516 Жыл бұрын
We need more videos!
@Laserbeanification
@Laserbeanification Жыл бұрын
Hey I have been enjoying your tutorials. I'm curious if you plan on returning?
@Billioncompany786
@Billioncompany786 2 жыл бұрын
Hey! Can you make Tutorial on Monopoly/Businessman Board Game in Unity 2D ?
@NotTolik708
@NotTolik708 2 жыл бұрын
it's genius
@T3QN1Q
@T3QN1Q 2 жыл бұрын
GIVE ME ALL YOUR LOOT
@BMoDev
@BMoDev 2 жыл бұрын
Nah
@Stompin40
@Stompin40 Жыл бұрын
Pog
@petervandeheuvel7322
@petervandeheuvel7322 Жыл бұрын
3 everyday.
@headed_weast
@headed_weast 2 жыл бұрын
If: ( blueEyedParents == true) {brownEyes(loot).dropChance = 0.00000000001}; Else: return;
@acatatofr
@acatatofr Жыл бұрын
the problem of this system is that this doesn't show real chances, like if there 70% rare item and 100% rare item, it would turns out, that 70% will pop up more times then 100%
@lee1davis1
@lee1davis1 Жыл бұрын
This video was just another regurgitated remake of other vids. So missleading.
@technofeeliak
@technofeeliak 2 жыл бұрын
At this point there are options. At this point there is one option. Please correct your speech. You're going to encourage bad habits for your audience.
@TheLunarah
@TheLunarah Жыл бұрын
I have this class in my lootPrefab, how can I access the name of the item there? I need somehow to access the lootName value public class Colectable : MonoBehaviour { private void OnTriggerEnter2D(Collider2D collision) { Debug.Log(gameObject.GetComponent().lootName); if(collision.tag == "Player") { Player player = collision.GetComponent(); if(gameObject.GetComponent().lootName == "Coin") { player.coins += 1; } if(gameObject.GetComponent().lootName == "Experience") { player.experience += 1; } Destroy(gameObject); } } }
@acatatofr
@acatatofr Жыл бұрын
the problem of this system is that this doesn't show real chances, like if there 70% rare item and 100% rare item, it would turns out, that 70% will pop up more times then 100%
Easy Enemy Health Bars in Unity
9:25
BMo
Рет қаралды 59 М.
Cinemachine Is Really Powerful, Set It Up EASILY
7:26
Support each other🤝
00:31
ISSEI / いっせい
Рет қаралды 81 МЛН
To Brawl AND BEYOND!
00:51
Brawl Stars
Рет қаралды 17 МЛН
Beat Ronaldo, Win $1,000,000
22:45
MrBeast
Рет қаралды 158 МЛН
Your Comment Randomizes This Game
3:51
BMo
Рет қаралды 8 М.
So I made every block act differently..
11:41
Element X
Рет қаралды 317 М.
I Made a Racing Game and My Viewers Destroyed It...
6:19
ZenDuck Apps
Рет қаралды 829
A Great Way To Setup POWERUPS In Your Unity Game
13:43
SAVE & LOAD SYSTEM in Unity
18:20
Brackeys
Рет қаралды 1,1 МЛН
CUTSCENES in Unity using Timeline
13:24
BMo
Рет қаралды 73 М.
Support each other🤝
00:31
ISSEI / いっせい
Рет қаралды 81 МЛН