Forum rules - please read before posting.

Set pop up variable to a random value?

Hey ya'll. I'm trying to set a pop up variable to a random value in the action list but it doesn't seem to be working correctly. Basically I want a character to move to A B or C. Then a timer runs and sets the popup Var randomly then he moves to another one at random. I know there's other ways to have him do this but I am curious about the "popup variable set as random" for future usage. Any help would be greatly appreciated. It seems he heavily favors option 1 and never hits option 3. I even tried making 4 options because I seen somewhere about it choosing one less than max. Is setting popup Var to random value just not good practice and clunky or am I missing something? Also I am doing this in a run in background local cutscene.

Comments

  • What are your AC and Unity versions?

    When the Variable: Set Action is used to set a PopUp value randomly, it uses Unity's provided Random.Range function (the "int" variant).

    The maximum value is set to the number of PopUp values available - so you shouldn't need to add an extra option for all to be potentially selectable.

    To test on my end, I created a PopUp variable with 3 values, and ran this Action on a loop. Though not all values were returned an equal number of times, they were all set.

    If you're finding that the results are skewed, you could try setting the seed value manually through script:

    using UnityEngine;
    public class SetRandomSeed : MonoBehaviour
    {
    
        public int seedValue = 100;
        void Awake () { Random.InitState (seedValue); }
    
    }
    
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.