- Home /
How to make a random team chance?
I'm making a game like murder on garrys mod, and i need to give a random chance to make someone murderer, bystander, and bystander W gun... I already got prefabs of the players with weapon scripts and the players got tags already also. all i need is a random chance for the player to become the murderer prefab. I'm using C++ btw :)
Answer by AcE_fLoOdEr · Feb 09, 2015 at 03:47 AM
#include <stdlib.h>
int main()
{
int random = rand() % 10 + 1;
}
that will generate a random number from 1-10. If you remove the +1 at the end, it will generate a number from 1-9.
by the way, how are you using C++ with unity? :/
Ah i meant C# im kinda new to this Haha And thank you btw :)
@jackolama oh, well in that case
int $$anonymous$$mChance = Random.range(0, 100);
// here you can have 50/50 chance
if($$anonymous$$mChance <= 50)
{
// $$anonymous$$m 1 plays
}
else
// $$anonymous$$m 2 plays
Your answer
Follow this Question
Related Questions
Jumpscare (Triggers and stuff) 1 Answer
Random Player Respawn Points 3 Answers
2D player stuck between BoxColliders 1 Answer
Clean way for percentages 0 Answers
How do I spawn a random prefab? 1 Answer