Flexible LOOT SYSTEM in Unity with Random Drop Rates

Flexible LOOT SYSTEM in Unity with Random Drop Rates

BMo

1 год назад

42,208 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

Ren Williams
Ren Williams - 04.09.2023 07:58

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.

Ответить
Nifoozmemeir
Nifoozmemeir - 28.08.2023 09:27

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

Ответить
itsspider
itsspider - 09.08.2023 17:14

my items dont stop moving, why?

Ответить
HrSkully
HrSkully - 07.08.2023 21:11

Very Helpfull and good Tutorial!!! Thanks a lot! It is exact what i needed

Ответить
Su
Su - 03.08.2023 20:27

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. :)

Ответить
SeaderWerks
SeaderWerks - 19.07.2023 20:11

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.

Ответить
Neff The Panda
Neff The Panda - 26.06.2023 07:13

trying to integrate this into Coding With Unity's inventory system tutorial but having a really hard time

Ответить
Dariusz Węsierski
Dariusz Węsierski - 15.06.2023 22:58

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

Ответить
acatato Real
acatato Real - 09.06.2023 03:28

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%

Ответить
acatato Real
acatato Real - 09.06.2023 03:28

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 - 24.05.2023 23:56

This video was just another regurgitated remake of other vids. So missleading.

Ответить
Pablo Goñi
Pablo Goñi - 18.05.2023 14:06

is there a way that instead of using sprites use a gameobject?

Ответить
CokeVoAYCE
CokeVoAYCE - 09.05.2023 08:49

thanks. easy, simple, complete and concise.

Ответить
Wei Cui
Wei Cui - 08.05.2023 14:37

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

Ответить
Tom M
Tom M - 03.05.2023 03:15

Pog

Ответить
Mayesa Widi Andita
Mayesa Widi Andita - 22.04.2023 15:25

How do you write a function to retrieve loot items?

Ответить
Beandigo Gaming
Beandigo Gaming - 20.04.2023 08:55

Hey I have been enjoying your tutorials. I'm curious if you plan on returning?

Ответить
Denis Oliveira
Denis Oliveira - 31.03.2023 04:26

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<Loot>().lootName);
if(collision.tag == "Player")
{
Player player = collision.GetComponent<Player>();

if(gameObject.GetComponent<Loot>().lootName == "Coin")
{
player.coins += 1;
}
if(gameObject.GetComponent<Loot>().lootName == "Experience")
{
player.experience += 1;
}

Destroy(gameObject);
}
}
}

Ответить
Denis Oliveira
Denis Oliveira - 31.03.2023 02:54

Thank you

Ответить
David Zero
David Zero - 23.03.2023 23:54

Hello I have a question: Is it safe to use public for lootList? Can't it modified by a player?

Ответить
Royceton Vosloo
Royceton Vosloo - 16.03.2023 03:38

Epic Video, Just found your channel, trying to figure out some stuff, magically it appeared. Great Content!!!! Hope your channel grows

Ответить
MarcosGameDev
MarcosGameDev - 11.03.2023 21:18

Can i use this for a 3d game?

Ответить
Sela
Sela - 21.02.2023 12:27

Very nice!
And now I'm gonna steal it.
Thank you!

Ответить
darkbatu
darkbatu - 10.02.2023 21:42

how can works for 3d objects?

Ответить
viktor pavlovskiy
viktor pavlovskiy - 06.02.2023 20:45

how can I adapt this for 3D?

Ответить
최은스타
최은스타 - 06.02.2023 19:08

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?

Ответить
Ba tak
Ba tak - 21.01.2023 12:41

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?

Ответить
KRAXI
KRAXI - 17.01.2023 01:35

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 Action<Enemy>OnEnemyKilled; 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

Ответить
Shamus Donaldson
Shamus Donaldson - 16.01.2023 21:58

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<SpriteRenderer>().sprite = droppedItem.lootSprite;

//assign tag function
if(droppedItem.lootName is "Shield")
{
lootGameObject.tag = "Shield";
}
}
}

Ответить
tomkc518
tomkc518 - 08.01.2023 04:34

We need more videos!

Ответить
Jonathan Dirks
Jonathan Dirks - 04.01.2023 19:34

Hey man. I just found your channel and I love you tutorial style. Very helpful!

Ответить
cheetah
cheetah - 04.01.2023 13:27

hey bmo how can i pick up the items that dropped like an ammo box

Ответить
Nika Man
Nika Man - 28.12.2022 04:36

Im so lucky that i picked up Unity again after years during the time u have started uploading content mate

Ответить
Casey Strong
Casey Strong - 24.12.2022 18:11

Underrated channel! Keep up the excellent content

Ответить
Raydamick
Raydamick - 22.12.2022 21:52

hey I was just wondering how to differentiate the items from each other, since they all come from 1 prefab

Ответить
Ngọc Hồ
Ngọc Hồ - 16.12.2022 21:40

Thank you Sir
Can you make a video how to make a Quest system ?

Ответить
Jayden Vogt
Jayden Vogt - 15.12.2022 18:58

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

Ответить
John Smith
John Smith - 10.12.2022 15:14

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.

Ответить
Rafał Gleich
Rafał Gleich - 09.12.2022 22:53

Hey BMo! Is there a chance to get a tutorial on Quick Time Events in Unity, please?

Ответить
BillionaireMEDIA
BillionaireMEDIA - 01.12.2022 22:33

Hey!
Can you make Tutorial on Monopoly/Businessman Board Game in Unity 2D ?

Ответить
Arturo Escobar
Arturo Escobar - 12.11.2022 07:01

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.

Ответить
Mitchell Knirnchild
Mitchell Knirnchild - 09.11.2022 17:23

Hey, your tutorials are amazing and you deserve millions of subs.... Loving watching and learning from you so far!!

Ответить
Gaming Gables
Gaming Gables - 01.11.2022 03:56

Awesome video! I had a question on using this for 3D game objects. Instead of using "GetComponent<SpriteRenderer>().sprite" could I use GetComponent<MeshRenderer>()? Not sure what the equivalent would be when working in 3D. Thank you for your excellent content!

Ответить
MAHESH CHARY INDRAKANTI
MAHESH CHARY INDRAKANTI - 28.10.2022 18:21

Ty I got my first divine because of you

Ответить
boboye daniel
boboye daniel - 28.10.2022 17:54

As always, everything is super. Waiting for new cheats from your side

Ответить
Lunaris356
Lunaris356 - 28.10.2022 03:47

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!

Ответить
Queso
Queso - 26.10.2022 23:31

You, sir, have earned my sub and like.

Ответить
T3QN1Q
T3QN1Q - 26.10.2022 23:19

GIVE ME ALL YOUR LOOT

Ответить
Sn0man
Sn0man - 26.10.2022 23:08

Great lesson here. Very clearly shows the fundamental to getting an RNG loot system in place.

Ответить
Mari
Mari - 26.10.2022 21:49

i would love a tutorial for an shop system like enter the gungeon or neon abyss

Ответить