Getting Started

This section will guide you through the process of installing RNGNeeds from the Unity Asset Store and quickly setting up your first probability list.


1. Open the Unity Editor
Start by opening your Unity Editor. Make sure you have a project open, or create a new one if necessary.

2. Access the Unity Asset Store
Navigate to the Unity Asset Store from within the Unity Editor. You can do this by clicking on Window from the menu bar and selecting Asset Store from the dropdown menu.

3. Search for RNGNeeds
In the search bar of the Asset Store, type in "RNGNeeds" and hit Enter. The RNGNeeds plugin should appear in the search results.

4. Download and Import the Plugin
Click on the RNGNeeds plugin from the search results to open its page. Here, click on the Download or Import button (the button's label will depend on whether you have downloaded the plugin before). If a window appears asking you to upgrade, you can just click Continue.

Once the download is complete, Unity will automatically prompt you to import the plugin into your project. Make sure all the files are checked in the Import Unity Package window and click Import.

5. Verify the Installation
After the import is complete, a Welcome Window should pop up. It provides handy links to our documentation, a getting started guide, instructions for importing samples, and a direct shortcut to the RNGNeeds preferences window.

To verify the installation, open RNGNeeds Preferences Window by either clicking on the shortcut button, or navigate through the Unity Menu:

  • On Windows - click on the Editor Menu Bar » Edit » Preferences.
  • On Mac - in the top bar, click on Unity » Settings

In the window that appears, click on RNGNeeds in the left part.

After opening the RNGNeeds preferences window, a message about loading default preferences and color palettes should appear in the console.

RNGNeeds Inspectors

Quick Start

To start using probability distribution in your project, add the generic ProbabilityList<T> class to one of your classes, or create a new script by right-clicking in the Project panel and choosing Create » C# Script

For this example, we will create a biased die that rolls the six a bit more often. Name the script Die and open it.
Inherit from ScriptableObject and add a Probability List of type int.

Adding the ProbabilityList

using UnityEngine;
using RNGNeeds;

[CreateAssetMenu(fileName = "dXX", menuName = "My Die")]
public class Die : ScriptableObject
    public ProbabilityList<int> die;

In Unity Editor, right-click on the Assets folder and choose Create » My Die. This will create a new Scriptable Object with the suggested name dXX. We will create a 6-sided die, so name the object D6 Die. Clicking on the object will display its properties in the Inspector, where you will see the Probability List Drawer.

Empty ProbabilityList

To add items into the list, click on the Add button on the right. These items will represent the sides of our die. Add six sides and specify their values.

ProbabilityList with items

Currently, the probabilities of items are even. We want to make the die roll the six more often, but retain the even chances among the other sides.

Click on the 'side 6' probability 16.67% and type in 0.2 (for 20%) and hit Enter. Probabilities of other items will drop to 16%.

Direct Input

Now it's time to roll the die. In RNGNeeds, you can select a value from the ProbabilityList easily by calling .PickValue(). Let's make our die object useful by adding a function that returns the roll.

Selecting values from list

using UnityEngine;
using RNGNeeds;

[CreateAssetMenu(fileName = "DXX", menuName = "My Die")]
public class Die : ScriptableObject
    public ProbabilityList<int> die;
    public int Roll()
        return die.PickValue();

Now, whenever you call Roll() on one of your dice, you will get a single int value based on probability distribution.

What's Next?

Congratulations on setting up RNGNeeds and taking your first steps into the world of advanced probability control! However, there's still a lot more to discover. To help you navigate and make the most out of RNGNeeds, we recommend diving into the following resources:

Exploring the Basics

Start by getting a strong grasp of the fundamentals. These articles will guide you through the user interface, introduce you to key terminology, and help you customize your setup via the Preferences Window:

Explore the RNGNeeds Example Usage