I am trying to stack up a number of objects on top of each other using a for loop and instantiating them with a prefab, this all works fine but I have 1 problem.
This is the code I use:
using UnityEngine;
using System.Collections;
public class SpawnScript : MonoBehaviour
{
public GameObject TargetPrefab;
void Start ()
{
for (int i = 0;i < 5; i++)
{
Instantiate(TargetPrefab, new Vector3(i * 0.9f, 0f, 0f), Quaternion.identity);
}
}
}
this works fine and it makes the 5 cubes I want with the 0.9 offset, but then I want to make another layer on top of it with the same 0.9 offset only then I want it to start more to the right because I want to stack the objects like a pyramid, but this way it always starts at 0, how do I set the start position to anything I want, while keeping the offset at 0.9?