Rental assets are a really easy way to create consumable items for your game that are removed after a set amount of time. So that’s things like boosters, buffs, skills, or cooldowns for abilities, as well as consumable items like potions, herbs, or strength enhancers. You can do this either as a timed booster, or a temporary buff or debuff for your game.
Rental assets are great for in-game rewards, time-limited events, claimable items during an in-game event… the list goes on. A rental asset can also contain other assets – so you can make these as simple or complex as you want.
Before we begin, make sure you've created your free LootLocker account, and installed and configured the Unity SDK into your game project.
You’ll also need to have got to grips with a few other LootLocker concepts before you can start using rental assets. Those are:
All sorted? Then let’s begin.
Let’s have a look at rental assets in action. In this example, we’re using the rental asset to activate a consumable booster for the player to use. When that happens a particle effect plays for the same length of time as the rental asset.
Remember that you need to activate rental assets – they can’t be equipped. So if your rental asset contains other assets, you’ll first need to activate the rental asset. Then, if you want the player to equip it directly, equip the items you get in return from the response.
Get the player’s inventory with the GetInventory()-function. LootLocker will then return information for all the assets in the player’s inventory.
We can then run a check to see if it’s a rental asset, and if the player’s consumed it, by checking the rental.time_left property on the asset. If the time_left is 0 or below, that means the rental asset isn’t active anymore, and shouldn’t be shown in the inventory. If the time_left isn’t up, we can show it in the player’s inventory with the function HandleItem().
In this example we’re running the UseItem()-function when the player clicks the asset in their inventory, which checks if they can equip the item. If they can, we run LootLockerSDKManager.EquipIdAssetToDefaultCharacter() to do that.
Next we check if it’s a rental asset. If it’s a yes, we activate it by running LootLockerSDKManager.ActivatingARentalAsset(), and send in the asset instance ID we got from the previous response.
We’ve now activated the rental asset on the server. That means it’ll be removed from the player’s inventory after a specific length of time. So we need to start a timer with the same duration as the rental asset, and display a particle effect during this time. When the time’s up, the particle effect ends.
One thing to remember – when players quit or pause the game in the middle of an active rental, the timer on the server doesn’t stop. So you’ll need to ask the server for the remaining time left on the rental asset again to keep it in sync.
And that’s it – rental assets, done.
Hopefully, you’re now super comfortable with rental assets. Don’t forget about LootLocker’s other features though – they’re all really quick and easy to set up. And if you need some help, we have lots of guides available.
Get in touch on Twitter or Discord. And if you like these guides, please let me know by tweeting me directly – I’d love to hear from you.