Getting Started

This page shows the fastest path from installing RNGNeeds to making your first working weighted list in Unity. If you are evaluating the plugin, this is the best page to confirm what the setup flow actually looks like and how little code you need to get value from it.

By the end of this guide, you will have RNGNeeds imported, a ProbabilityList<int> visible in the Inspector, and a small reusable die example that demonstrates how weighted picks work in practice.


Installation

Make sure RNGNeeds is already available in your Unity account. Open your Unity project and follow these steps to import it.

1. Open the Package Manager
In the Unity Editor, go to Window » Package Management » Package Manager.

2. Find RNGNeeds in My Assets
In the Package Manager window, select My Assets from the left sidebar under Sources. You should see RNGNeeds - Probability Distribution listed among your assets. Click on it to select it.

3. Import the Plugin
With RNGNeeds selected, click the Import button on the right side of the Package Manager window. If prompted, make sure all files are checked in the Import Unity Package dialog and click Import.

4. 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