0

Hi iam trying to build a game in which the skater will skate on the irregular terrain which is 2D and side scrolling. Iam not getting how to instantiate a terrain dynamically and in different shapes along x-axis.. I want to achieve something like this http://thegoldenmule.com/labs/TerramorphicGenesisAlgorithms/. Please help.

CodeSmile
  • 64,284
  • 20
  • 132
  • 217
RakeshChatra
  • 105
  • 1
  • 4
  • 9

3 Answers3

4

Assuming you're referring to the 'circle hill' setting on the demo you linked, here's what I'd try:

Step 1: generate some nice 1D noise. My guess is the linked demo is only using two octaves, so I'd start with that. These points will end up being spread apart when you generate pixels for the actual line. It looks like the linked demo had them about 50 pixels apart.

Step 2: use spline interpolation to get values between the points generated in step 1.

To get a sense of how this works, try this demo (make sure to change the setting to cubic spline though). You'll probably need to experiment with the parameters of step 1. My hunch is you'll want to avoid noise that it too erratic & you'll need to space the resulting points out a bit. Something like this:

enter image description here

Alternatively, when I was looking for a spline demo/library, I came across Curvy - it might provide what you want & save you the time of rolling your own code. If not, there are probably other spline libraries out there that might work.

Pikalek
  • 926
  • 7
  • 21
3

I spent quite awhile looking for this and couldn't find much. I finally decided to create my own solution - if you are trying to accomplish this in Unity, I created an asset which will do this for you. For some of the theory behind it, Prime 31 has a good youtube video that explains the general approach to take.

Neil
  • 737
  • 1
  • 8
  • 23
0

Try this asset from unity asset store.

This is very small, easy to use. Although graphics is pretty bad, you can put some shader or pp effect.

Maifee Ul Asad
  • 3,992
  • 6
  • 38
  • 86