GML [SOLVED/BUG]Persistent Objects on paths, moved during room switch.

M

Megamini009

Guest
Hello,

So at the moment Im working on a game that has multiple enemies with set paths in room 1.
They are currently set to persistent.

When I go to room 2, the paths are unaffected, but the instances are all moved.
The y being the biggest change which changes it to minus whatever its y was previously.

E.g In Room 1, the enemy.y = 320, after returning to Room1 from Room2, the enemy.y = -320

It seems to be only a problem with the Objects on Paths, as the other objects in Room1 which are also persistent, remain in their correct positions.

Any ideas and suggestions would be appreciated, I can post up code blocks if needed.
Thank you for looking !


Update: It seems it always shifts the y coordinate by -638...

Update: OKAY so It turns out that the Coordinates are being shifted BY the coordinates of the instances starting point.
The instances all start their path at -96 , 638.
And it would appear that instances on a path are actually having their starting point subtracted from their current position.

Update: It is in fact the Enemy objects that are being moved and not the paths themselves.
 
Last edited by a moderator:
M

Megamini009

Guest
So, issue was persistent. I tried making a simple project with only 2 rooms and one object on a path.

And the issue is still here.

Basically when an object is on a path, its coordinates subtracted by its origin points. After changing rooms.

I need them to stay on their coordinates.

I tried reseting them to an older variable, but it comes across that theres a loop constantly pushing them back to their origin points.... anyone with ideas?
 
C

CyberSCK

Guest
In the create event of your object do you have the 'absolute' modifier set to true in the path_start() function? Also don't manually set the x and y of the object on a path.
 
M

Megamini009

Guest
In the create event of your object do you have the 'absolute' modifier set to true in the path_start() function? Also don't manually set the x and y of the object on a path.
Currently I have it set to false, but I have tried it with absolute and unfortunately the same issue occured.
 
C

CyberSCK

Guest
Can you post the code you're using? Also when you change rooms does the object continue along the path just with the wrong coordinates or does it stop moving altogether?
 
M

Megamini009

Guest
[/CODE]
Can you post the code you're using? Also when you change rooms does the object continue along the path just with the wrong coordinates or does it stop moving altogether?
So the object continues on its path which is set to persistent.

The only code I've made so far is the creation of the object.

2 Rooms made using the Room editor. The first also being persistent

And a button to switch between the rooms.

Code:
path_start(Test_Path, 4, path_action_reverse, 0);
 
It does seem like a bug to me. You should report it.

The workaround I came up with is:

Persistent Enemy Create event
Code:
path_pos = 0
path_start(path0, spd, path_action_stop, true)
Persistent enemy Room end Event
Code:
path_pos = path_position
Persistent enemy Room Start Event
Code:
path_start(path0, spd, path_action_stop, true)
path_position = path_pos
 
M

Megamini009

Guest
It does seem like a bug to me. You should report it.

The workaround I came up with is:

Persistent Enemy Create event
Code:
path_pos = 0
path_start(path0, spd, path_action_stop, true)
Persistent enemy Room end Event
Code:
path_pos = path_position
Persistent enemy Room Start Event
Code:
path_start(path0, spd, path_action_stop, true)
path_position = path_pos
Thank you, I'll report it now.

And your solution works great, I just need to adjust it to suit random path choices in my game, will update again once my game is on track.
Thank you again!
:)
 
M

Megamini009

Guest
Just wanted to say that the game is now back up and running. Thank you for the help and hopefully they are able to fix this bug for future :)
 
It does seem like a bug to me. You should report it.

The workaround I came up with is:

Persistent Enemy Create event
Code:
path_pos = 0
path_start(path0, spd, path_action_stop, true)
Persistent enemy Room end Event
Code:
path_pos = path_position
Persistent enemy Room Start Event
Code:
path_start(path0, spd, path_action_stop, true)
path_position = path_pos
Thank you so much for this. And thanks for posting OP :)
 
Top