1. Hello Guest! It's with a heavy heart that we must announce the removal of the Legacy GMC Archive. If you wish to save anything from it, now's the time! Please see this topic for more information.
    Dismiss Notice

GM:S 1.4 Pause path

Discussion in 'Programming' started by Sk8dududu, Nov 30, 2019.

  1. Sk8dududu

    Sk8dududu Member

    Joined:
    Aug 14, 2017
    Posts:
    197
    So I have a bunch of paths that have anywhere from 4-10 points each. The object following the path needs to pause for about 1 second each time it reaches a new point in the path. Then continue onto the next point.
    Not sure how to go about checking if the path is different.
     
  2. Catastrophe

    Catastrophe Member

    Joined:
    Sep 22, 2019
    Posts:
    222
    I'm not a path expert, but if you need a working solution it'd be something like this:

    Create:
    mypath = stuff
    curPoint = 1;
    nextPointX = path_get_point_x(mypath,1)
    nextPointY = path_get_point_y(mypath,1)

    step:

    if (point_distance(x,y,nextPointX,nextPointY) <= speed) {
    x = nextPointX
    y = nextPointY
    // we're at the next point
    < do your pausing stuff >
    curPoint++
    nextPointX = path_get_point_x(mypath,curPoint)
    nextPointY = path_get_point_y(mypath,curPoint)
    }
     
    Last edited: Nov 30, 2019
    Sk8dududu likes this.
  3. Sk8dududu

    Sk8dududu Member

    Joined:
    Aug 14, 2017
    Posts:
    197
    This seems to work perfectly for the first point. The objects starts the path, pauses at the first point in the path where i have an alarm set to increase path speed again.
    But every point after that it just fly's right past.
     
  4. shortbread

    shortbread Member

    Joined:
    Nov 28, 2019
    Posts:
    6
    Can you post your implementation? Seems like the nextPointX & nextPointY aren't updating.
     
  5. Sk8dududu

    Sk8dududu Member

    Joined:
    Aug 14, 2017
    Posts:
    197
    All i did was pathspeed = 0 and alarm_set(1,30) where it stops in the step event.
    And then in the alarm i set pathspeed = 5.
     
  6. shortbread

    shortbread Member

    Joined:
    Nov 28, 2019
    Posts:
    6
    Its hard to debug without seeing your actual code and the conditions to execute those statements, I'd recommend you use the debugger or show_debug_message() to log the values of the points and see where the issue pops up.
     
    Sk8dududu likes this.
  7. Catastrophe

    Catastrophe Member

    Joined:
    Sep 22, 2019
    Posts:
    222
    It would make sense if there was an issue here:

    curPoint++
    nextPointX = path_get_point_x(mypath,curPoint)
    nextPointY = path_get_point_y(mypath,curPoint)

    If you forgot any of these lines or had a typo in them this won't work

    But yeah, debugging yourself or pasting your alarm code would help. The important parts are the values of curPoint, nextPointX and nextPointY

    Alternatively, "speed" might be incorrect in the if statement, I think it should be path_speed, or possible something involving path_speed. I would try:

    if (point_distance(x,y,nextPointX,nextPointY) <= path_speed) {

    and just as a sanity check

    if (point_distance(x,y,nextPointX,nextPointY) <= (path_speed + 5)) {
     
    Last edited: Dec 1, 2019
    Sk8dududu likes this.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice