- Home /
i want to spawn randomly
![alt text][1]
in this picture there is 5 blocks for now think that blocks has 5 color and i want to shuffle that blocks ho do i do that [1]: /storage/temp/108337-block.png
Just to clarify, what you want is to shuffle the blocks' positions after their colors are set, right?
Answer by FlaSh-G · Jan 01, 2018 at 06:37 PM
Put a script on the block prefab (or each block, if you have none). The script could just look like this:
using UnityEngine;
public class SCRIPTNAME : MonoBehaviour
{
private void Start()
{
GetComponent<SpriteRenderer>().color = Color.HSVToRGB(Random.value, 1, 1);
}
}
This is assuming you are using SpriteRenderers.
Your answer
Follow this Question
Related Questions
I want to swap randomly 5 blocks (block has 5 diffrent color) and spawn in vertical line 1 Answer
script not working pls solve it 1 Answer
Spawn objects at random position ON a 2D object. 1 Answer
Best way to manually calculate collision between GameObjects and a Tilemap without using physics 1 Answer
Any Unity game cause my phone (Vernee mix 2) to freeze. 0 Answers