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.
@@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
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"; } } }
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
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?
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;
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
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!
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?
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!
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.❤❤
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. :)
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.
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
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
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.
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
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%
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!
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
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.
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); } } }
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%
A book, a fish, and a gem walk into a bar….. and Bmo’s at it again with that good content
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.
Im so lucky that i picked up Unity again after years during the time u have started uploading content mate
Great lesson here. Very clearly shows the fundamental to getting an RNG loot system in place.
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.
Epic Video, Just found your channel, trying to figure out some stuff, magically it appeared. Great Content!!!! Hope your channel grows
Underrated channel! Keep up the excellent content
Very nice!
And now I'm gonna steal it.
Thank you!
Hey man. I just found your channel and I love you tutorial style. Very helpful!
At right place, at right time! Thx for tutorial)
Hey, your tutorials are amazing and you deserve millions of subs.... Loving watching and learning from you so far!!
Appreciate ya
@@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
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";
}
}
}
Great video! Very helpful! I am very enthusiastic!!!!
Very Helpfull and good Tutorial!!! Thanks a lot! It is exact what i needed
thanks. easy, simple, complete and concise.
You, sir, have earned my sub and like.
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
Great idea, and thanks for that!
hey I was just wondering how to differentiate the items from each other, since they all come from 1 prefab
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
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
Thanks appreciate that, it looks like it goes to 1080p now, you may have caught it early enough when it was still processing
@@BMoDev Oh yea, nice! I'm sorry I said bad quality instead of low resolution or some XD
how can I adapt this for 3D?
it says list doesnt have a definition for lootsprite what do i do
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?
Ty I got my first divine because of you
Idk what that means but I'm glad
for some reason when the loot scriptable objects have the same dropChance value only one of them ever spawns and cancels out the other
How do you write a function to retrieve loot items?
i would love a tutorial for an shop system like enter the gungeon or neon abyss
is there a way that instead of using sprites use a gameobject?
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?
same problem here haha
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;
how can works for 3d objects?
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
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!
@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.
Same, if you got solution please update.
Can you be more clear please? I'm not sure to understand your issue
Why arent there 2xn lists for the unity editor? or is there a way to get one?
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?
Thank you Sir
Can you make a video how to make a Quest system ?
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!
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.❤❤
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. :)
how do i incorporate this with the inventory system
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?
trying to integrate this into Coding With Unity's inventory system tutorial but having a really hard time
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.
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
My gem always move when it was created and not stop like you ?? how can I fix this
up the mass and friction in rigidbody
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
Hello I have a question: Is it safe to use public for lootList? Can't it modified by a player?
hey bmo how can i pick up the items that dropped like an ammo box
my items dont stop moving, why?
Same if i found a solution i will let you know
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
thx a lot, but how i use them? like add script to the loot so i use them
Hey BMo! Is there a chance to get a tutorial on Quick Time Events in Unity, please?
Thank you
Can i use this for a 3d game?
As always, everything is super. Waiting for new cheats from your side
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.
wouldnt that just allways drop the new prefab you created?
We need more videos!
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
Hey I have been enjoying your tutorials. I'm curious if you plan on returning?
Pog
it's genius
Hey!
Can you make Tutorial on Monopoly/Businessman Board Game in Unity 2D ?
GIVE ME ALL YOUR LOOT
Nah
3 everyday.
If: ( blueEyedParents == true) {brownEyes(loot).dropChance = 0.00000000001};
Else: return;
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%
This video was just another regurgitated remake of other vids. So missleading.
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!
did you solve the problem?
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
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.
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);
}
}
}
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%