Legacy GM [Solved] Removing a paths points...

C

CrazyOmar

Guest
Hello.
I'm testing some gameplay features right now and one of them is an ability that forces all players (or the only one yet) to "travel back in time". This is achieved by adding a point to a path every few steps and reversing this whole path when activating said ability.

Now, it would be bad if the player gets reversed to the first position he entered the room at. That's why everytime there are more than 30 points for example, the first one gets deleted. The problem is that the whole path is kind of moving in random directions at this moment which doesn't help that much. This doesn't happen if the first point never gets deleted so it has to do with the deletion.

Is there a way to fix that problem?

My code:
Code:
if(path_get_number(path) > 30) {
    path_delete_point(path,0);
}
Thanks for your support.
 

johnwo

Member
Is your path open or closed?
Use path_set_closed(index, closed); to set it to open, then see it that helps!

Cheers!
 
C

CrazyOmar

Guest
Sadly, it's already open. I also tried path_set_kind and path_set_precision for instance but the problem starts when a point is deleted for the first time.
It may be because GameMaker can't handle the frequently updated path but why would every point move in one direction?

The path is also absolute, btw. And when reversing, no new points are being added.
 
Last edited by a moderator:
A

Aura

Guest
The best way would be to keep a 2D array with 30 slots with two subslots each where position is stored every few steps.

Code:
for (var i = 1; i <= 30; i++)
{
    time_array[i - 1, 0] = time_array[i, 0];
    time_array[i - 1, 1] = time_array[i, 1];
}
time_array[30, 0] = x;
time_array[30, 1] = y;
Now when you want to go back in time, add points to the path on the go.

Code:
//path_clear_points(path0);
for (var c = 30; c >= 0; c--)
{
    path_add_point(path0, time_array[c, 0], time_array[c, 1], 100); // you may use path_change_point()
}
Hope that helps~
 
Top