Cita de: gZone date=1513560577
using UnityEngine;
public class nada : MonoBehaviour {
public int min, max;
public GameObject sphere;
public LineRenderer traza;
void Start () {
var nEsferas = 8;
traza = gameObject.AddComponent<LineRenderer> ();
traza.startWidth = traza.endWidth = .2f;
traza.numPositions = nEsferas;
for (int i = 0; i < nEsferas; i++) {
var posiciona = GeneratedPosition ();
Instantiate (sphere, posiciona, Quaternion.identity);
traza.SetPosition (i, posiciona);
}
}
Vector3 GeneratedPosition () {
float x, y, z;
x = (float) Random.Range(min, max);
y = (float) Random.Range(min, max);
z = (float) Random.Range(min, max);
return new Vector3(x, y, z);
}
}
Gracias me ayudastes full, de todo corazón. Con este codigo, genero dos esferas(roja y azul), como hago para que la esfera azul se una con la linea a la esfera roja, Dios te bendiga y muchas gracias.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class nada : MonoBehaviour
{
public int min, max;
public GameObject sphere;
public LineRenderer traza;
void Start()
{
var nEsferas = 8;
traza = gameObject.AddComponent<LineRenderer>();
traza.startWidth = traza.endWidth = .2f;
//traza.numPositions = nEsferas;
traza.positionCount = nEsferas;
for (int i = ; i < nEsferas; i++)
{
var posiciona = GeneratedPosition();
var posicionaD = GeneratedPosition();
var posiciontotal = GeneratedPosition();
GameObject origin = Instantiate(sphere, posiciona, Quaternion.identity);
origin.GetComponent<Renderer>().material.color = Color.red;
GameObject destino = Instantiate(sphere, posicionaD, Quaternion.identity);
destino.GetComponent<Renderer>().material.color = Color.blue;
traza.SetPosition(i, posiciona);
}
}
Vector3 GeneratedPosition()
{
float x, y, z;
x = (float)Random.Range(min, max);
y = (float)Random.Range(min, max);
Esta sección te permite ver todos los mensajes escritos por este usuario. Ten en cuenta que sólo puedes ver los mensajes escritos en zonas a las que tienes acceso en este momento.
#16