This is my code :
using UnityEngine;
using System.Collections;
using System.CodeDom;
public class convert : MonoBehaviour {
public GameObject[] cubes;
// Use this for initialization
void Start () {
cubes = new GameObject[5];
Vector3[] pos = new Vector3[5];
for (int i = 0; i <= 5; i++) {
pos_.x = cubes*.transform.position.x;*_
if (pos_.x == cubes*.transform.position.x) {
pos.x = pos[(int)Random(0,5)].x;*_
* }*
* }*
* }*
* // Update is called once per frame*
* void Update () {*
* }*
}
public GameObject cubes;
void Start () {
Vector3 pos = new Vector3[5];
for (int i = 0; i <cubes.Length; i++) {
pos_.x = cubes*.transform.position.x;_
if (pos_.x == cubes.transform.position.x) {
// if you want pos.x to be random use this line :
pos = new Vector3 (Random.Range(0,5),pos.y,pos.z);
print(pos);
// but if you want cubes.x position to be random use this line instead :
cubes .transform.position = new Vector3 (Random.Range(0,5),cubes.transform.position.y,cubes.transform.position.z);
}
}*_
Change “Random” to Random.Range
. You are referencing the class instead of a method of the class.