How do i Instantiate gameObjects in between multiple points?

Hello i am having some trouble trying to instantiate GameObjects in between multiple points, but i am not getting the results that i want. This is what i am trying to achieve in Pic1, and the results i am getting in Pic2 if anyone know’s how to do this?


Here is the code so you know what i have done

using UnityEngine;
using System.Collections;

public class Points : MonoBehaviour {

    public Transform[] points;
    public GameObject GameObj;
    public float GameObjectAmount = 2;
	void Start () {
        for (int i = 0; i < points.Length; i++)
            Instantiate(GameObj, points*.position / GameObjectAmount, Quaternion.identity);*
  • }*


I’m not sure what you are trying to do with the calculation:

points*.position / GameObjectAmount*

But it looks wrong to me.
If I am reading your question correctly, I THINK you want to instantiate between the points…
for (int i = 0; i < points.Length-1; i++)
Instantiate(GameObj, Mathf.Lerp(points_.position, points*.position, .5f), Quaternion.identity);
Note the points.Lenght-1 in the loop, you’ll need that or you will go out of bounds._

// Yawn… Probably something like this. Didn’t test it because… well, I’m working on my game at the moment and didn’t want to clear the current scene for you :stuck_out_tongue:
public class Points : MonoBehaviour
public Transform points; // I’m assuming this is coordinate of all your sugar cube.
public GameObject GameObj; // Object you want to duplicate
public float GameObjectAmount = 2; // Why is this float, you cannot have “half” a game object :wink:

    void Start()
        duplicateObject(GameObj, (int) GameObjectAmount);

    public void duplicateObject(GameObject original, int howmany)
        howmany++; // Because Logic!
        for (int i = 0; i < points.Length-1; i++)
            for (int j = 1; j < howmany; j++)
                Vector3 position = points_.position + j * (points[i + 1].position - points*.position) / howmany; // Because Logic!*_

Instantiate(original, position, Quaternion.identity);