Hello! I’m trying to modify a Vector3 variable so it spawns an object at random coordinates, however it gives me errors about casts floats, and doubles. Does anyone know how to correctly modify a Vector3 variable? Sorry for all the question asking.
using UnityEngine;
using System.Collections;
public class BacteriaParts : MonoBehaviour {
public GameObject ribosome;
public GameObject ribo1;
public Vector3 spawn1;
public string ribo1ID;
// Use this for initialization
void Start () {
ribosome = GameObject.Find ("Ribosome");
if (ribosome == null) {
Debug.Log ("A Ribosome to copy can't be found");
}
else {
Debug.Log
("The Instance Id of the Ribosome is" + ribosome.GetInstanceID().ToString());
}
//Set spawn coordinates of Ribosome
spawn1.x +=0.01 * Random.Range (1, 10);
spawn1.y +=0.01 * Random.Range(1, 10);
spawn1.z += -1;
//Instantiate the Ribosome
ribo1 = Instantiate (ribosome, spawn1, Quaternion.identity);
//Save ID for other scripts to use
ribo1ID = ribo1.GetInstanceID().ToString();
Debug.Log ("ribo1 has an InstanceID of" + ribo1ID);
}
// Update is called once per frame
void Update () {
}
}