RANDOM LOOT Table in Unity - GACHA System

  Рет қаралды 10,990

Dev Leonardo

Dev Leonardo

Күн бұрын

Пікірлер: 33
@DevLeonardo
@DevLeonardo 4 жыл бұрын
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!
@DevLeonardo
@DevLeonardo 4 жыл бұрын
Hey Fajar, welcome on the channel! In which game are you going to give out random items? :)
@christopherlegg6200
@christopherlegg6200 2 жыл бұрын
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!
@DevLeonardo
@DevLeonardo 2 жыл бұрын
Thank you so much! This means a lot to me ❤
@michelangelomarino9251
@michelangelomarino9251 4 жыл бұрын
Very well done mate, thanks to your video I understand a way better now about random multiple item
@DevLeonardo
@DevLeonardo 4 жыл бұрын
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
@michelangelomarino9251
@michelangelomarino9251 4 жыл бұрын
@@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.6115
@fredericc.6115 4 жыл бұрын
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!
@DevLeonardo
@DevLeonardo 4 жыл бұрын
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.6115
@fredericc.6115 4 жыл бұрын
Wow thank you so much for this thoughtful reply. I'll explore your suggestions. Cheers! 🙂
@DevLeonardo
@DevLeonardo 4 жыл бұрын
@@fredericc.6115 Good luck with the implementation! :D
@contot4084
@contot4084 Жыл бұрын
Great video! Your code is also awesome. Thank you so much!
@Me-zd5tn
@Me-zd5tn 7 ай бұрын
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
@totallynotdevs4691
@totallynotdevs4691 2 жыл бұрын
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.. }
@DevLeonardo
@DevLeonardo 2 жыл бұрын
It doesn't have to be sorted, it works with any order :)
@totallynotdevs4691
@totallynotdevs4691 2 жыл бұрын
@@DevLeonardo mmmh I tried to use the debug of visual studio and it always start from the first of the list.
@DevLeonardo
@DevLeonardo 2 жыл бұрын
@@totallynotdevs4691 that's correct, goes through the list but stops at a random point
@totallynotdevs4691
@totallynotdevs4691 2 жыл бұрын
@@DevLeonardo But in that case depend on how you populate the list I think
@Me-zd5tn
@Me-zd5tn 7 ай бұрын
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?
@WZDZ
@WZDZ 2 жыл бұрын
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_
@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
@DevLeonardo
@DevLeonardo 2 жыл бұрын
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
@MrGoochPlays
@MrGoochPlays 3 жыл бұрын
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?
@DevLeonardo
@DevLeonardo 3 жыл бұрын
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 :)
@MrGoochPlays
@MrGoochPlays 3 жыл бұрын
@@DevLeonardo awesome, how would you reward the player with multiple items ? For example, maybe a sword, piece of equipment and a potion or two?
@DevLeonardo
@DevLeonardo 3 жыл бұрын
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 :)
@hikkathon
@hikkathon 4 жыл бұрын
And how to make them not unite and go after each other created swords?
@DevLeonardo
@DevLeonardo 4 жыл бұрын
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
@hikkathon
@hikkathon 4 жыл бұрын
@@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)
@DevLeonardo
@DevLeonardo 4 жыл бұрын
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 :)
@callum4479
@callum4479 2 жыл бұрын
Thanks for this :)
@chebucreker
@chebucreker 2 жыл бұрын
You are help me, thanks!
@DevLeonardo
@DevLeonardo 2 жыл бұрын
You're welcome, thank you for subscribing!
Make money from a SKIN SHOP in your Game in Unity!
10:40
Dev Leonardo
Рет қаралды 7 М.
Flexible LOOT SYSTEM in Unity with Random Drop Rates
13:24
Cat mode and a glass of water #family #humor #fun
00:22
Kotiki_Z
Рет қаралды 42 МЛН
The Power of Scriptable Objects as Middle-Men
17:41
samyam
Рет қаралды 132 М.
I Made the Same Game in 8 Engines
12:34
Emeral
Рет қаралды 4,3 МЛН
Unity Devs Try Godot: Can we make a game in 12 HOURS?
8:19
Inner Chaos Games
Рет қаралды 20 М.
Drop Loot Auto Flyback to Player with Unity
6:10
Indie Nuggets
Рет қаралды 20 М.
Item Drops (2D Unity Tutorial)
11:36
Night Run Studio
Рет қаралды 6 М.
I Coded a Nuclear Physics Simulator to Play God in VR
44:21
Thomas Wald
Рет қаралды 122 М.
Random Drops in Unity
3:41
Vector Bread
Рет қаралды 15 М.
How to Create a RANDOM LOOT TABLE in Unity C#
15:56
gamedev:hq
Рет қаралды 63 М.
Coroutines in Unity (how & when to use them)
12:35
Game Dev Beginner
Рет қаралды 32 М.