Place models defined at runtime

Modified on Fri, 22 Jun 2018 at 01:04 PM

The code below creates an array of voxel definitions and populates it with the voxel definition #1. Then uses the method ModelPlace to add the content to the scene in front of the camera.

Note that you can use your own voxel definitions defined at runtime as well.


int sizeX = 12, sizeY = 12, sizeZ = 12;
VoxelDefinition[,,] model = new VoxelDefinition[sizeY, sizeZ, sizeX];
VoxelDefinition vd = env.GetVoxelDefinition (1);
for (int y = 0; y < sizeY; y++) {
    for (int z = 0; z < sizeZ; z++) {
        for (int x = 0; x < sizeX; x++) {
            model [y, z, x] = vd;
        }
    }
}

VoxelPlayFirstPersonController fpsController = VoxelPlayFirstPersonController.instance;
env.ModelPlace (Camera.main.transform.position + Camera.main.transform.forward * 100, model);

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select atleast one of the reasons

Feedback sent

We appreciate your effort and will try to fix the article