# How does he...

0 favourites
• 3 posts
• ...do this?

https://pbs.twimg.com/tweet_video/CKdaBzJUMAAVmDd.mp4

Not that I want to copy it, just curious as to how this can be achieved and if it can be achieved in Construct, wobbly line that isn't a shader which is 'physical' geometry

• The shape of the line is done with the sum of multiple sine waves.

A single sine wave would look like this:

y = a*sin(b*time+c*x+d)

a is the amplitude of the wave

b is the speed of the wave

c is the frequency of the wave

d is just an offset

The interesting slopes can be done by adding more than one of those waves together as long as they have different values for a,b,c and d.

So then we have an equation that gives a y position from a x position. That can be used to place the trees, since they just move up and down.

Getting the angle of the curve at any point just requires some basic calculus. Just take the derivative of the equation above with respect to x and we get:

slope = a*cos(b*time+c*x+d)*c*pi/180

Then the angle can be found from the atan of the slope:

angle = atan(slope)

Here's an example:

https://dl.dropboxusercontent.com/u/542 ... rrain.capx

I used iid but I could have just as well used x, also the lines have gaps which could be fixed with better line drawing.

That pretty much covers what it looks like is done in that video. To have other objects move about on that surface you'll need to do it manually. I make a ski example a while back that probably could be referenced.

• ## Try Construct 3

Develop games in your browser. Powerful, performant & highly capable.

Construct 3 users don't see these ads
• Very helpful and interesting, learning a lot from this.

Thanks!