- Home /
Random role assignment (Documentation only!)
This is a continuation of a previous post where I wrote: "I have a system in place where I have a list of roles, cops /robbers, which is assigned in the inspector in the form of a string. How can I write a script which randomly assigns all agent a role, either cops or robbers , every time I start a new game?"
Since then I was given a script but, after having tinkered with it for a while, I realized that wasn't what I needed. There already exists scripts which allow you to randomly change material of an object based off a list I was wondering if it was possible to the same for an array of strings in this case called roles?
I need documentation ONLY no scripts please.
Answer by Stratosome · Jul 29, 2018 at 10:28 PM
Well, if you have an array of strings, you could generate a random index using int randIndex = Random.Range(0, array.Length - 1)
and then retrieve the string using array[randIndex]
. If you did this inside of the Start function, you could use this to accomplish what you're wanting?
No, I already have a script to work with I only need documentation.
Oh, what do you mean by documentation then?
Well the problem is that I have an ill defined problem and adding more lines of code with only complicate it further. The simplest way I can describe it is that I have a static public Dictionary<string, List<Agent>> agentByType;
and I want to be able to assign these agentsByType to a random Agent everytime I start a new game.
Your answer
Follow this Question
Related Questions
Physic Material Friction Combine Mode lack of documentation? 2 Answers
Generating (HTML) documentation for Unity Script (not C#) ? (like Doxygen) 1 Answer
Networking Destroy Player's RPC function uhm WHAT? 1 Answer
uGUI API Documentation 2 Answers
Current (5.3) Documentation (Manual and Scripting Reference) Download 2 Answers