Resources

Core comes with a built-in system of resources. A player can gather a lot of different resources in your game. Some basic objects are already created in Core so you don’t have to code to get started with this feature. Resources can be used as coins, gems, stones, or any kind of resources in your game.

The two objects of this lesson

Resource Pickup

This object is an item that can be gathered by the player when colliding with it. By default, it will add 1 resource of type “Gems” to the player. This is defined in the Custom Properties of the Resource Pickup object. The HealthChange value is useful to heal the player when they grab the resource, that is the easiest way to make a medkit in your game! You can also define a MaxResource amount and a PickupEffects that will be spawned when the player gathers the item.

Custom Properties of the Resource Pickup

In the Hierarchy, you will find the Trigger that detects the player, the script that gives the resource to the player, and a Geo_ClientContext folder containing the model of the resource, here, a gem. To change the model of the resource, remove the gem and add another asset in the Geo_ClientContext folder.

Resource Pickup Hierarchy

Try it on Core! Add 5 coins that you can gather by walking on them. The resource should be called “Coins” and not “Gems”.
Coins will disappear when colliding with them.

Resource Display

The Resource Display is showing the amount of a specific resource for the current player. In the Custom Properties, you must define the ResourceName with the same value as the one you set in the Resource field of the Resource Pickup object. If AlwaysShow is disabled, the popup is shown during the number of seconds defined in the PopupDuration.

Custom Properties of the Resource Display

The UI can be updated in the ResourceDisplayContainer. You can change the Background, Icon, and Text aspects. If you want to move the whole thing at another place of the screen, update the Panel object. Use the Dock and Anchor properties to make a UI that can adjust to any display. For example, if you want your resource to stay at the middle bottom of your screen, set the Dock property to Middle Bottom. Now, try to change the width of the viewport, the Panel will stay in the middle.

Default UI
Icon changed
Updated UI

Try it on Core! Add a Resource Display object to your scene that shows the resource “Coins”. Update the Icon and use a coin icon instead of the coin bag.

Post a comment

Leave a Comment

Scroll to Top