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
78
S
25
G
9
Posts: 85
Reputation: 9,255

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
92
S
32
G
110
Posts: 5,295
Reputation: 71,501

Post » Thu Aug 03, 2017 4:47 am

ImageImageImage
B
71
S
22
G
241
Posts: 3,734
Reputation: 134,494

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
78
S
25
G
9
Posts: 85
Reputation: 9,255

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
92
S
32
G
110
Posts: 5,295
Reputation: 71,501

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
169
S
50
G
174
Posts: 8,331
Reputation: 110,806

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,493
Reputation: 20,950


Return to How do I....?

Who is online

Users browsing this forum: brunopalermo, dand, MadSpy, mekonbekon, tinhofiel and 32 guests