Paths?

This forum is currently in read-only mode.
From the Asset Store
Move around the rectangular and travel as much as you can!
  • 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?

  • 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.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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

    <img src="http://upload.wikimedia.org/wikipedia/commons/f/ff/Bezier_3_big.gif">

    as you can see t is a value which when changed moves the paths returned position along. it should be a number from 0 to 1. 0 meaning its at the complete beginning of the path, 1 meaning its at the absolute end. 0.5 would mean the center. imagine if you multiplied the number by 100 it would be the percent moved along the path. so 0.25 would be 25% and so on.

    if you would like to move your object back and forth along the path at a certain speed simply add a small number like 0.01 to the t value. so it will take 100 frames to move it from p0 to point p3.

    a value less than 0 or greater than 1 will simply move the object to a position that would exist if the curve were to continue at its current amount of deviation

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)