Procedural Questions

Well, i want to use the procedural system to create a unique terrain every time i open the game. But Unity just gives an error every time i try to load the procedural assets, so i gave up on them, for now.

What i want to know is if i have a block (say, of material limestone) and i make that a prefab, can i use a script to “assemble” them together to create a unique structure… Given the terrain under foot?:face_with_spiral_eyes:

Also, How do I allow for terrain morphing? (say, i have a road being built, and i determine that i want a tunnel here, how do i allow the tunnel to “morph” the terrain)

When you run into an error of some sort, don’t assume that that means you can’t do whatever it is you’re trying to do. There are many reasons errors can be generated, and usually such errors simply reflect an oversight or a problem with the implementation. (Although it is possible that the error is related to a limitation of Unity, a simple way to find out for sure would be to ask about it on the forums.)

Sure, you can do that.

You currently can’t put holes in the terain, but you can reshape it in other ways. Do a search for Terrain and TerrainData
and see here in the docs

Thank you.
I was just checking to see it it was possible before attempting it.

As for the error, I gave up on loading the procedural assets for now, but i intend to either “break them open” and copy/paste them into new scripts or create my own biased upon the method used, but this is unimportant

Also, is there any example of a code to “assemble” blocks?

There’s a lot of examples floating around, so you never know what you might find on the forums or the Wiki, but I don’t know of an example off the top of my head that shows exactly that.

In any case, here’s one way to do it:

  1. Give your blocks box colliders.

  2. Raycast (use Camera.ScreenPointToRay() to build the ray) and check to see if a block has been hit.

  3. If so, use the intersection normal to determine on what side of the block to add a new block.

  4. Compute the coordinates for the block using some simple arithmetic and vector math (perhaps snapping to a 3-d grid to correct for any numerical error).

  5. Use Instantiate() to create a block at the new position.

i was going to try a 2-d grid to “lay” the block onto, then offset the 2d grid by 1/2 block and lay another course

I know the math is rather simple, that is one reason why i thought about build this way.

Another is because since each is a component, I only need (a) SIMPLE 3D block(s) to build everything (i will prob. have at least 10 different kinds)
and my final reason is that i can TEAR it apart when it gets hit

I read the tutorial on instantiate(), but Raycast (Camera.ScreenPointToRay) is new to me.

Coliders are internal scripts, so i really don’t need to do anything for that, and i figured i prob would need to use that