What's up, game devs? Feel free to share here your game where you used this script, I'd love to see that! Oh, and don't forget to subscribe to get notified about new content!
@DevLeonardo4 жыл бұрын
Hey Fajar, welcome on the channel! In which game are you going to give out random items? :)
@christopherlegg62002 жыл бұрын
I appreciate you putting everything up front before the main part of the video. I'll make sure to watch til the end and give you a like. It's not much, but I appreciate you!
@DevLeonardo2 жыл бұрын
Thank you so much! This means a lot to me ❤
@michelangelomarino92514 жыл бұрын
Very well done mate, thanks to your video I understand a way better now about random multiple item
@DevLeonardo4 жыл бұрын
Hey Michelangelo, that's great to hear! I hope you'll also enjoy the other content of my channel :) Have fun with your GameDev journey and see you soon! PS: Leonardo here, now we only need Raffaello and Donatello to complete the gang :P
@michelangelomarino92514 жыл бұрын
@@DevLeonardo ahahah yep ninja turtles. Anyway there is a way to contact you directly because I went trough all your code and I wuold like to implement in my game but still there are some stuff that I don't understand properly and I wuold like to ask you a bit of stuff
@fredericc.61154 жыл бұрын
Nice video, thank you very much for sharing! Quick question please: if you had a big loot list (with hundreds of items), what would you use as a table editor? Excel sounds a good candidate, but are there simple ways to go from Excel to scriptable object? Cheers!
@DevLeonardo4 жыл бұрын
Hey Frédéric, welcome to my channel! That's indeed an interesting question. If you are familiar with Excel, you can stick with it! You use Excel to work on all the data and balancing, then you can write a C# script that can be manually executed from the Unity Editor (just a script with the MenuItem decorator) and what your script does is read the Excel file (there are plenty of C# libraries for that), parse the content and generate the ScriptableObjects. To avoid duplicates you could assign an ID to each item (each row on excel to make it easy?) so that the generation script avoids creating two ScriptableObjects with the same ID and just updates the values if you run the script multiple times. If you can't make it work direclty from Excel to Unity, you can still work on Excel, add an extra step that is manually converting the sheet in a JSON file (you can use an online tool) and then feed the object generation script with the JSON. Working with JSON is usually quite easy as they're exactly meant for being read and navigated. These are just a few hints, I hope it helps!
@fredericc.61154 жыл бұрын
Wow thank you so much for this thoughtful reply. I'll explore your suggestions. Cheers! 🙂
@DevLeonardo4 жыл бұрын
@@fredericc.6115 Good luck with the implementation! :D
@contot4084 Жыл бұрын
Great video! Your code is also awesome. Thank you so much!
@Me-zd5tn7 ай бұрын
Maybe this is tricky but what if I want the probability of every item be a result of a Google Form? For example, I made a form where the users can choose between items A, B and C and I want the system to generate the probability ratio base on how many times people choose those options. Meaning that, if in a group of ten people A was chosen 5 times, it has a 50% chance to be selected in my gacha system and if B was chosen 3 times, it would have a 30% chance to appear
@totallynotdevs46912 жыл бұрын
Hi, awesome video! I have one question. I noticed that you kinda "sorted" manually the weight of every item from the list of the scriptable object. As someone already said i have different item with different weight and i can't apply it manually (i can but would be really bad) Do you think that in the foreach part can i sort automaticcally with this part of code? foreach(var item in items.OrderByDescending(it => it.weight)) { Do stuff.. }
@DevLeonardo2 жыл бұрын
It doesn't have to be sorted, it works with any order :)
@totallynotdevs46912 жыл бұрын
@@DevLeonardo mmmh I tried to use the debug of visual studio and it always start from the first of the list.
@DevLeonardo2 жыл бұрын
@@totallynotdevs4691 that's correct, goes through the list but stops at a random point
@totallynotdevs46912 жыл бұрын
@@DevLeonardo But in that case depend on how you populate the list I think
@Me-zd5tn7 ай бұрын
Maybe this is tricky but what if I want the probability to chage based on the results of a Google Form? That can be done?
@WZDZ2 жыл бұрын
I'm a little confused. If the diceRoll is lower than the item.weight it gives you the item? I Debug.Log the diceRoll and the item but sometimes the roll would be higher than the weight and still give the item? For instance if i set a Dagger to 0.01, shouldnt the diceRoll have to be lower than that to obtain it? How comes it will only work with certain numbers? This is an issue I'm having in unity.
@MackEZ_2 жыл бұрын
how would you go about adding this into an enemy drop? I was hoping to get it so when the loot is dropped it then decides what it will be based off of the loot table I made
@DevLeonardo2 жыл бұрын
You could create a "loot" table that is actually an enemy table, so that the content instead of items is enemies :D You pick an enemy and then you spawn it
@MrGoochPlays3 жыл бұрын
What would happen if two items have the same weight, would you get 2 rewards? or is it a 50% chance to get one or the other?
@DevLeonardo3 жыл бұрын
Hey Faine, welcome to my channel! Each iteration rolls one item only, so if you have two possible items with 50% it's a coin flip, it either gives the first or the second :)
@MrGoochPlays3 жыл бұрын
@@DevLeonardo awesome, how would you reward the player with multiple items ? For example, maybe a sword, piece of equipment and a potion or two?
@DevLeonardo3 жыл бұрын
You need three different tables (one per type of items) and you can do as many rolls as you want. You can also roll a dice to see how many rewards. For example you roll a number from 1 to 4 and if it's a 3 you give 1 sword, 1 equip and 1 potion. If it's a 1 you only give a sword... it's entirely up to you, all combinations are possible :)
@hikkathon4 жыл бұрын
And how to make them not unite and go after each other created swords?
@DevLeonardo4 жыл бұрын
Hey! Thanks for the question and welcome to the channel :) I think I'm not entirely sure what you mean by going after each other created sword, could you please expand the question? :P
@hikkathon4 жыл бұрын
@@DevLeonardo I'm wondering how you can remove the grouping of items by the number so that when generating all items spawn one after another)
@DevLeonardo4 жыл бұрын
If you really need it, you can set the items list (List _items, on LootTable.cs) as public, so that you can access the list everytime you want, and "manually" generate items from there, one by one :)