0 Favourites

# Paths?

This forum is currently in read-only mode.
• 6 posts
• I was wondering if there was a way to set a predefined path in Construct. Let's say for example I have a path that isn't straight from A to B and want the player to move towards B along the path if I hold the right arrow down, and vice-versa for the left arrow.

Is this possible?

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

Construct 3 users don't see these ads
• there are ways to do something like this

how were you planning to define the path though?

• there are ways to do something like this

how were you planning to define the path though?

I'm not sure... in GameMaker there is a path editor where you can just define points and reuse it as many times as you want. If such a feature doesn't exist, it'd be nice to add one!

• Object path behaviour has been discussed, and I believe it will be added at some point, but until then what most of us do is:

1. Create some sprites to use as your waypoint objects. Usually a small circle or an "X" will do.

2. On the startup, you can use a loop to set a private variable, say "pointnumber" for example, to each point based on position, or depending on the path (IE straight line, around in circle, etc) you could use the UID of each object.

3. Get enemy or whatever you want to follow the path, make it have a "destination" variable. On startup if will look for "pointnumber" 1, then on contact with point 1, its destination will change to "pointnumber" 2, etc etc.

That's probably the best way. You can also make it change speed, size, animation frame, etc based on its destination variable.

~Sol

• Or, well, if you've got a way with numbers, you can use polinomial functions to define the path. Y'know, splines and stuff.

• bezier curves do this nicely

simply set position to

X= cubic(p0.x,p1.x,p2.x,p3.x,variable('t'))

Y= cubic(p0.y,p1.y,p2.y,p3.y,variable('t'))

the p#'s are sprites which define the paths points. p0 would be the point the path starts at, p3 would be the one it ends at. the other 2 control the curvature of the path like so