How do I get an object to follow a curved path.

Get help using Construct 2

Post » Thu Aug 03, 2017 3:40 am

Hi,

I am working on a form of path-finding for my game. On a move command, it will calculate a path for the player using "nodes".

What i'm trying to work out is this: my player moves to node 1, and then cuts at a sharp angle to node 2 (following the red path here: http://i.imgur.com/FOgFuOv.png), which looks a bit odd. I am trying to gradually curve the player around objects (using the nodes as a guide) so that the player follows something more like the green path shown in the image, instead.

Can anyone think of a formula/approach to get the player to curve it's position gradually as it approaches a node?
(Using: player.x, player.y, node1.x, node1.y, node2.x, node2.y)

I think the Sine behavior might be of use, but this one's got me stumped.
B
64
S
21
G
7
Posts: 74
Reputation: 7,477

Post » Thu Aug 03, 2017 4:16 am

There's these ideas:
viewtopic.php?f=147&t=153545&p=967749&hilit=Catmull+rom#p967749

I'll need to check later to update my links.

The formulas are usually a bit too lengthy to remember.
B
91
S
31
G
103
Posts: 5,235
Reputation: 67,756

Post » Thu Aug 03, 2017 4:47 am

ImageImageImage
B
71
S
21
G
221
Posts: 3,649
Reputation: 124,227

Post » Thu Aug 03, 2017 5:43 am

@R0J0hound
@blackhornet

Thanks for the links guys! I came across this page: https://www.particleincell.com/2012/bezier-splines/ and it looks similar to what I need. That said it isn't perfect.

In any case, I think the math involved is beyond me. Even if I were to implement it following the bezier spline method, you'll notice how there is an "unnecessary" curve between the first two nodes: http://i.imgur.com/fULycxI.png

I don't need my object to follow the path perfectly, but rather simply curve around the edges (when closer to the nodes) with the goal of just making the movement smoother, do you know of a simpler way to implement something that can achieve this?
B
64
S
21
G
7
Posts: 74
Reputation: 7,477

Post » Thu Aug 03, 2017 4:43 pm

You could just use the "rotate to angle" action to gradually turn to a object. It will be smooth but not symmetrical.
B
91
S
31
G
103
Posts: 5,235
Reputation: 67,756

Post » Thu Aug 03, 2017 8:16 pm

Colludium made a very nice behavior:
behavior-tween-tween-js-and-bezier-easing_t187854
Image ImageImage
B
168
S
50
G
164
Posts: 8,228
Reputation: 105,575

Post » Thu Aug 03, 2017 10:03 pm

rexrainbow Has a Spline approach.
behavior-rex-spline_t178563
B
33
S
18
G
28
Posts: 2,470
Reputation: 20,904


Return to How do I....?

Who is online

Users browsing this forum: vegapomme27 and 10 guests