I have this code to set random x and z coordinates for several game objects:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
public class SetPositions : MonoBehaviour
{
// Use this for initialization
void Start ()
{
System.Random rnd = new System.Random();
int a = rnd.Next (-9,9);
int b = rnd.Next(-9,9);
transform.position = new Vector3(a, transform.position.y, b);
}
}
When I use this script with multiple game objects, mot of them end up in the exact same location. I have gathered that this has something to do with the time being used, but how to I make sure all of the objects are in different positions?
Aucun commentaire:
Enregistrer un commentaire