Unreal Engine 4 Tutorial - Weighted Loot Table

preview_player
Показать описание
Learn how to implement a loot table component for your enemies to drop random weighted loot.

Subscribe now to catch each video as they are released each week.

Рекомендации по теме
Комментарии
Автор

EDIT: in the Choose Loot function you should use a less than or equals (<=) instead of a less than (<) comparison. This will solve the rare occurrence of a null response.

RyanLaley
Автор

Great tutorial!
As someone in the comments mentioned, this approach would always favor items with lower array indices.
To solve this, one could loop through the options and us the "Random bool with Weight" as a breakout condition (after the weights have been calculated and assigned).

LAxemann
Автор

Ended up making it a map with classes:float
Selected my BP_PickupBase as the class then added the children pickups to the map.
Then connected the output to spawn actor connecting the class output directly to it.
Worked perfectly, thanks so much.

mbwilding
Автор

It's actually kind of insane how perfectly this resolves an issue I've been having with a randomized limb-damage mechanic I've been working with for the past couple days. Yesterday I finally came up with a solution that worked for me, but it's nowhere near as easy as the logic you have for this loot drop system! Thank you so much for sharing this, I can't wait to replace my logic in favor of this! Not to mention I had no idea about actor components, so that's a nice bonus!

SamFuller
Автор

Thank you for the tutorial. I would be very happy to see it not with a string, but with items (weapons etc)

ikebroflovski
Автор

!!FOR ANYONE WHO NEEDS HELP GETTING THIS CODE TO WORK WITH AN ACTOR LOCATION!! An actor dies, this code runs to spawn something where it died.

Say you want this code to be called when an actor gets destroyed, I am currently using this for my little game and it works flawlessly. Here is a link to the simple steps you need to follow. Ryan if you see this, thank you so much for this. I hope this could help people as well!


This is essentially all I had to do, after the Choose loot event, I plugged in my enumerator which just lists all of my types of pickups/collectables. This could be different depending on what you need this code to do of course. Plug that into the switch, as I have in the image, and run a spawn actor event for each of the nodes. Use a Get Owner plugged into a GetActorLocation and plug that into the location for the Spawn Actor, and you should be set! Move over to the actor that will be dropping the loot, ensure the loot component is already on that actor of course, then just plug in the Drop Loot event, and it should work perfect!

AGGStudios
Автор

im new to unreal, and your tutorials are very practical and useful!

Assassin
Автор

This is fantastic... So far I have just put loot into a list, and if I want an item to be more rare, I was adding more of all the other items, getting a super long list in the end.. I will give this a shot, Thank you very much!!

reeanimationgaming
Автор

Having them show on ground would be great

djshiro
Автор

This worked great! Thanks! For some reason I could not get the last item in the list to spawn. The result was always -1, even if I set everything else to 0 and the last one to 100. The Only way I could get it to work properly was to add 1 extra item to the list with 0 chances, and it works perfectly! No idea what I did wrong, but I thought I'd share this in case someone else was having a similar problem. (I was using Integers instead of floats, maybe this was the issue?)

richmakesgames
Автор

This is exactly what I was looking for, thanks for sharing

Christopherseander
Автор

As always - thank you for the vids! thought I would share that I just tried dragging your "LootTable" from the youtube video into my BP... guess I need another coffee LOL

moragna
Автор

Would you like to cover how to create weapons with different parts randomized on the weapon?

ihusitusi
Автор

Hi Ryan, will you be making a video about dropping loot into the world (perhaps from monsters)? Still very interested in seeing that. Thanks!

captainsavage
Автор

Hey thanks for this video! One question, is this supposed to be the proper way to get a fair randomness? I mean, wouldn't the last objects on the map list have less chances of getting chosen due to the iteration order?

glosmolt
Автор

Plz do the Second Video to handle spawning of items in the world.

xantishayde-walker
Автор

Did you made the video you were talking about?

حاتمإسماعيل-بر
Автор

Great Video! Helped me out a lot! Thanks (:

ZL
Автор

Was able to follow along fine until the end. For some reason, I can't add the Loot Table actor as a component to my enemy (doesn't show up when I search for it). I can drag and drop the Loot Table from content browser, but I guess that only does so as a child, which is causing some connection issues. Don't know if this is an engine difference or not, but I'll try and manage!

*2 seconds later*
*Sees that I'm using Actor instead of Actor Component :)*

dawnrigel
Автор

Hello Ryan! Can you do something on finding the best way to Sort an inventory and by different categories like most amount or alphabetical order or rarity and price?

ty_teynium