New to Unity and C#
This is actually just a small issue that I'm curious about... I ran into it while tweaking this code in a (failed) attempt to make it work. I have been trying to get this code to work for a few hours now.
Anyway, when this code is executed, there is only one error, but it appears 3 times. It says "Can't destroy Transform component of 'Pillar1'. If you want to destroy the game object, please call 'Destroy' on the game object instead. Destroying the transform component is not allowed."
First time I've gotten THAT.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlatformGenerator : MonoBehaviour {
public GameObject Single;
private GameObject NewPillar;
private int PillarCount;
private bool run;
private int px;
private int py;
private int pz;
void Start () {
px = 0;
py = 0;
pz = 0;
bool run = true;
PlatformCreate ();
}
void Update () {
if (run) {
PlatformCreate ();
if (PillarCount == 3) {
run = false;
}
}
}
void PlatformCreate () {
PillarCount +=1;
Single.transform.position = new Vector3 (px, py, pz);
NewPillar = Instantiate (Single, Single.transform);
NewPillar.name = "Pillar" +PillarCount;
px += 2;
}
}