- Home /
Is it possible to do this for a random terrain approach?
Hi guys,
I've read a little bit into generating random terrains using the heightmap function. I was wondering if there is a way to employ the brush from Unity's terrain tools to build the terrain in runtime.
My plan is to lay down a piece of terrain say 1000 by 1000. Generate a random x and y coordinate. Generate a random height and radius for the brush and hit that coordinate. Repeat until I have all the hills and plateaus I need.
Is this doable? does it already exist? I'm pretty new to programming, just looking for some good reference material to get started.
Thanks!!
EDIT: I'm revitalizing this question cuz its hard to believe there's no response for this. I have attached a picture in the comment of what I'm looking to make my sample terrain look like. Let me know if this makes "???" appear in your brain, I can clarify further.
I just saw your comment on my question and was about to come over to help with this, but it looks like you have an answer! I was going to suggest perlin noise, but this answer by jmatthews looks more specialized, shall have to have a look myself. Thanks @jmatthews =]
Yeah, it looks more specific than your typical perlin noise generator. I've used those before, it really wouldn't work for what I'm trying to do.
$$anonymous$$y main goal is to be able to have broad flat pla$$anonymous$$us of specific heights (see above). Depending on the height, that would deter$$anonymous$$e what gameobjects get instantiated on them. If its low, its sandy beach and gets palm trees and ocean monsters, if its high, its a mountain and gets trolls and yetis.
Also, I need broad flat areas so my buildings and things I instantiate don't appear half off of a cliff. Which is why I commented on your racetrack question, Alucardj. Looks like you're doing something similar.
Answer by jmatthews · Apr 04, 2013 at 08:31 PM
I'm not certain whether it is possible to use the brushes programmaticly, however I am sure that randomly selecting an x,y and applying the brush will end up a mess and not at all what you're trying to accomplish.
To generate random terrain you'll want to look at a library called LibNoise. it's been ported to Unity and here is a link to it.
A simpler approach that you can read through and play with is here read that short article and port the code to C# or UScript,(i have it at home if you get stuck but it is worth the effort trying to port it just to appreciate the simplicity of it.
Either of these will give you good results and don't require the Unity brushes.
And to think I was just opening a new post on forums to copy this question over and delete it. Thanks, this looks like a good start. $$anonymous$$y problem with other random terrain generators is that they've been completely out of control sharp and craggy. This looks like what i need!
those pla$$anonymous$$us are going to be some additional coding. If you go with the robot frog implementation I'd use the hill generator code that selects x,y groups and then code a custom "flattening" function for them. If you run in to issues pm me or something and I'll help out, I've been through a lot of noisy terrain code with Unity.
thanks man, it'll take me some time to get digging in to this but I'll keep you in $$anonymous$$d. I'm new to coding and unity.
Your answer
Follow this Question
Related Questions
Bugs with Terrian. Unity 5.4.0f3 FIXED 0 Answers
Painting Textures onto Terrain Via Script 0 Answers
How to make custom terrain textures 0 Answers
Is it possible to paint an animated texture onto a terrain? 4 Answers
Tree painter problem 1 Answer