Player spawning systems.

Hello, I’m currently working a robot game based off the cartoon network.com game, Dexter’s Bot Brigade.

So for my game, the player would place down a robot of one of three types, sort of a rock-paper-scissors system.

What I’m wondering, is how can I create a script that spawns a random one of these types for the player to use and?

I have already set the movement for one of the objects. So how might I create a spawning system for the player to get one of the robots?

Hello @Bluesharky38,

I’m happy to explain this more in depth if you need it, but roughly you just need to do the following:

public List<GameObject> robots;

Start()
{

}

public GameObject ChooseRobot()
{
    int randomNumber = Random(0, robots.Count - 1);
    return robots[randomNumber];
}

Then go into the inspector and set your list size and assign the robot prefabs to the slot. You can call this ChooseRobot() method any time you want a random robot. You might need to cast the Random() as an int, in which case it would be

(int)Random(0, robots.Count - 1);

Let me know if that helps or if you need further explanation.

-Jason