hi…
I try to make voxel project from this tutorial
http://alexstv.com/index.php/posts/unity-voxel-block-tutorial-pt-4. My problem is don’t no how to use these function… because i’m new in c#…
public void SetBlock(int x, int y, int z, Block block)
{
Chunk chunk = GetChunk(x, y, z);
if (chunk != null)
{
chunk.SetBlock(x - chunk.pos.x, y - chunk.pos.y, z - chunk.pos.z, block);
chunk.update = true;
//Add these lines line
UpdateIfEqual(x - chunk.pos.x, 0, new WorldPos(x - 1, y, z));
UpdateIfEqual(x - chunk.pos.x, Chunk.chunkSize - 1, new WorldPos(x + 1, y, z));
UpdateIfEqual(y - chunk.pos.y, 0, new WorldPos(x, y - 1, z));
UpdateIfEqual(y - chunk.pos.y, Chunk.chunkSize - 1, new WorldPos(x, y + 1, z));
UpdateIfEqual(z - chunk.pos.z, 0, new WorldPos(x, y, z - 1));
UpdateIfEqual(z - chunk.pos.z, Chunk.chunkSize - 1, new WorldPos(x, y, z + 1));
}
}
i have try for 2 day and still don’t no how to do… with these
public void add(){
RaycastHit hit;
if (Physics.Raycast (transform.position, transform.forward, out hit, 25)) {
World.SetBlock (hit, new BlockLeaves ());
}
}
i get error:
Assets/Code/AddRemove.cs(15,31): error
CS0120: An object reference is
required to access non-static member
`World.SetBlock(int, int, int,
Block)'…
what should i put in (int x, int y, int z,)?
i hope someone can clarify…