rIKmAN
Member
I've been chasing what I thought was a bug in my code for a few evenings, and finally managed to nail it down to an issue with path_start not initialising related variables (like path_position) for a couple of steps after it is called.
I've boiled it down to this simple example.
Create a path, and then start it in a Create Event:
Then in the Step Event:
Logging path_speed shows the correct values, however path_position always returns -1 and there is no movement of the instance when space is held down, it just remains static with a -1 path_position.
If I switch those values around things work as expected and the instance stops when space is held down and moves when it's released.
I then found that if I set an alarm for 2 steps in the Create Event and set a flag to true, and then wrap that keyboard check inside an if check for that flag being true, it then all works as expected.
(You can also use your own counter instead of an alarm of course, same result.)
So it seems like path_start is taking 2 steps to initialise, similar to how you can't use window_center until the frame after you change the window size, and when I set path_speed to 0 straight away it never gets chance to properly initialise and never starts.
I also noticed that if I set the initial speed in path_start to 0, then even using the 2 step delay doesn't work and the instance doesn't move at all - again with path_position returning a constant -1.
Can anyone confirm or have any ideas on what might be going on?
I was going to report it as a bug but was asked to post here first to see if anyone more familiar with paths could give any insight in case it's expected behaviour but undocumented or my understanding of what I expect to happen is off.
Thanks.
I've boiled it down to this simple example.
Create a path, and then start it in a Create Event:
Code:
path_start(pathPatrol, 0.5, path_action_restart, true)
Code:
if(keyboard_check(vk_space))
{
path_speed = 0.5;
}
else
{
path_speed = 0.0;
}
If I switch those values around things work as expected and the instance stops when space is held down and moves when it's released.
I then found that if I set an alarm for 2 steps in the Create Event and set a flag to true, and then wrap that keyboard check inside an if check for that flag being true, it then all works as expected.
(You can also use your own counter instead of an alarm of course, same result.)
So it seems like path_start is taking 2 steps to initialise, similar to how you can't use window_center until the frame after you change the window size, and when I set path_speed to 0 straight away it never gets chance to properly initialise and never starts.
I also noticed that if I set the initial speed in path_start to 0, then even using the 2 step delay doesn't work and the instance doesn't move at all - again with path_position returning a constant -1.
Can anyone confirm or have any ideas on what might be going on?
I was going to report it as a bug but was asked to post here first to see if anyone more familiar with paths could give any insight in case it's expected behaviour but undocumented or my understanding of what I expect to happen is off.
Thanks.