How do i Instantiate sub-Points with in Multiple Points??
Hello i am having trouble trying to make sub-Points(RedSphere) with in Points(Cube) and then add the
sub-Points(RedSphere) as childs to the Points(Cube), so i can move a Cube with its Sub-Points(Redsphere) attached to it, see in Pic1 so you know what i mean exactly. And here are the results i am getting which is in Pic2, does anyone know how to do this.
-Pic1 (i randomized the Cubes so you can tell what i mean) -Pic2 (The results i am getting with the code Below) And Here is the code so you know what i have done.
using UnityEngine;
using System.Collections;
public class Points : MonoBehaviour {
private Vector3[] cubePoints;
private Vector3[] spherePoints;
public GameObject cubePrefab;
public GameObject spherePrefab;
public int cubeAmount, sphereAmount, offset;
void Start()
{
cubePoints = new Vector3[(cubeAmount + 1)];
for (int i = 0, x = 0; x <= cubeAmount; i++, x++)
{
cubePoints[i] = new Vector3(x * offset, 0);
Instantiate(cubePrefab, cubePoints[i], Quaternion.identity);
}
spherePoints = new Vector3[(sphereAmount + 1)];
for (int i = 0, z = 0; z < sphereAmount; i++, z++)
{
spherePoints[i] = new Vector3(0, 0, z);
Vector3 position = spherePoints[i];
Instantiate(spherePrefab, position, Quaternion.identity);
position = cubePoints[i];
}
}
}
Your answer
Follow this Question
Related Questions
How to fix snake behavior in Unity3d? 0 Answers
Instantiating Objects randomly on a sphere with a set distance radius 0 Answers
I'm having a few issues with (Catmull)Splines that i need help with. 1 Answer
How do I Instantiate a prefab at the x axis position of where the UI button was clicked 1 Answer