Quantcast
Channel: Questions in topic: "clone"
Viewing all articles
Browse latest Browse all 508

Cloned objects choosing different colors

$
0
0
I have a game were a grid will spawn and i need the colors of each cube on the grid to randomize but everyone of them is a clone, currently when i press start simulation the cubes will go on flashing or will be all white or black (occasionally they will be half and half like their supposed to) **what am i doing wrong?** code: using System.Collections; using System.Collections.Generic; using UnityEngine; using System; public class Wall : MonoBehaviour { //get random System.Random rdn; //clone temp random private int _tempRnd; //textures public Texture2D White; public Texture2D Black; void Start () { //pick random and then input into clone temp random rdn = new System.Random(); _tempRnd = rdn.Next(1, 3); // send log for viewing Debug.Log(_tempRnd); //pick the number anc choose if (_tempRnd == 1) { GetComponent().material.mainTexture = White; } else { GetComponent().material.mainTexture = Black; } } }

Viewing all articles
Browse latest Browse all 508

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>