public bool platformMaxed = false;
public static int platformSpawned;
public GameObject PlatformPre;
public GameObject ParentObject;
public Transform platformChild;
void Start ()
{
StartCoroutine(PlatformSpawning());
}
public IEnumerator PlatformSpawning()
{
while (platformMaxed ==false)
{
for (platformSpawned = 0 ;platformSpawned <= 3; platformSpawned++)
{
Instantiate(PlatformPre,
new Vector3(Random.Range(-15,15),Random.Range(1,15),0),
Quaternion.identity);
Debug.Log("Platform Spawned" + platformSpawned);
if (platformSpawned >= 3)
{
platformMaxed = true;
break;
}
}
if (platformMaxed == true)
yield break;
yield return 0;
}
}
public void SpawnSinglePlatform()
{
Instantiate (PlatformPre,
new Vector3(Random.Range(-15,15),Random.Range(1,15),0),
Quaternion.identity);
Debug.Log("Platform Spawned" + platformSpawned);
}
void Update ()
{
}
What I need is, when the object is instantiated it gets parented to a Rotating Sphere object.
I can NOT use:
Transform platformChild;
platformChild = Instantiate(PlatformPre, New Vector3…) as Transform;
As that will give me the following error:
Setting the parent of a transform which resides in a prefab is disabled to prevent data corruption.
Alternatively, how would I go about rotating an object based on the pivot of another object?