How does he...

Get help using Construct 2

» Mon Aug 17, 2015 11:40 am

...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
B
44
S
13
G
8
Posts: 622
Reputation: 7,417

» Mon Aug 17, 2015 6:18 pm

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.
B
101
S
39
G
134
Posts: 5,588
Reputation: 85,514

» Mon Aug 17, 2015 8:09 pm

Very helpful and interesting, learning a lot from this.

Thanks!
B
44
S
13
G
8
Posts: 622
Reputation: 7,417