I am a new game programmer to Unity. I am currently trying to clone a single Transform called StoneBlock. The original StoneBlock exists in the Scene already. How would I clone this block and put it where the parameters specify and leave the original in its place?
I have attempted to do this using GameObject.Instantiate(), but it gives me errors saying:
BCE0005: Unknown identifier: ‘StoneBlock’.
Here is my code of my custom World class:
public static class World {
final var blocks : int = 1;
final var blockSizeX : float = 2.5f;
final var blockSizeY : float = 2.5f;
final var blockSizeZ : float = 2.5f;
public static function addBlock(blockId, x, y, z) {
var xp : float = x;
var yp : float = y;
var zp : float = z;
if (blockId == 1) {
var prefab = GameObject.Instantiate(StoneBlock.transform, Vector3(xp * blockSizeX, yp * blockSizeY, zp * blockSizeZ), StoneBlock.transform.rotation).gameObject;
//Instantiate(prefab, Vector3(xp * blockSizeX, yp * blockSizeY, zp * blockSizeZ), Quaternion.identity);
}
}
}
What am I doing wrong?
Look promising, I'll check it out in a while.
– pyroProgrammer2013