Zdravím
ako sa vypočíta v unity3d,vzdialenosť medzi novými vygenerovanými kockami,keď je gameObject array?
Ďakujem za rady
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class vehicless : MonoBehaviour {
[SerializeField] private GameObject[] vehicle;
[SerializeField] private Transform spawnPos;
[SerializeField] private float minTime;
[SerializeField] private float maxTime;
int randomInt;
// Use this for initialization
void Start () {
StartCoroutine(SpawnVehicle());
}
// Update is called once per frame
void Update () {
}
private IEnumerator SpawnVehicle(){
int i=1;
while(true){
randomInt=Random.Range(0,vehicle.Length);
yield return new WaitForSeconds(Random.Range(minTime,maxTime));
GameObject myPrefabInstance = Instantiate(vehicle[randomInt],spawnPos.position,Quaternion.identity);
var red = myPrefabInstance.gameObject.name; //NAME OBJECT
var namecube = red + i ;
// float dist = Vector3.Distance(transform.position, vehicle[0].transform.position);
// Debug.Log("Name object:"+ namecube) ;
i++;
}
}
}