Legacy GM Changing Path Followed with Creation Code

W

Wild_West

Guest
I have a grenade enemy that I want to be able to follow a different path in the room based on what I give it's path variable as a value, 1, 2, 3 ect..

I've toyed around with paths before and made a block object that follows paths the same way but that was based more on just which block was assigned an ID

Example : B1 = instance_find(path_block, 0);
with(B1) path_start(); and you get the picture, each block in the room will follow a different path using the B1 or B2 or however many IDs.

Now that works fine, but I'm trying to make it so I can do this same sort of thing only using creation code not an ID, as I want to be able to place as many jumping grenades in any room at a time without having to assign each one an ID to check for.

The issue is while working with paths I've noticed if I put them in the step event(which I don't even think your supposed to do right? :p) The object WILL move but completely ignore the path and just go in a stragiht line pretty much.
So I moved it to the create event to get it following the path correctly.
And this clashes with any create event stuff I'd need to get the creation code before the room start event working since putting creation code in the actual create event doesn't work.

I tried setting up a switch statement for the grenade that will change which path it follows in the creation code but that didn't work. Then I tried putting the switch in the step event and same results.

So finally, my question.
Is there a way to use paths in conjunction with creation code or room start code?
Or should I forget it and just use one path for all instances of my grenade enemy?
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
Have a controller object and in that set alarm[0] to one step. In the alarm 0 event of the controller, set the paths for the grenades. For example:

Code:
// CONTROLLER OBJECT CREATE
alarm[0] = 1;

// ALARM[0]  EVENT
with (obj_Grenade)
{
path = choose(path1, path2, path3);
path_start(path);
// or whatever...
}
In the grenade create event set the path variable to -1 so you don't get any issues later with uninitialized variables.
 
W

Wild_West

Guest
Have a controller object and in that set alarm[0] to one step. In the alarm 0 event of the controller, set the paths for the grenades. For example:

Code:
// CONTROLLER OBJECT CREATE
alarm[0] = 1;

// ALARM[0]  EVENT
with (obj_Grenade)
{
path = choose(path1, path2, path3);
path_start(path);
// or whatever...
}
In the grenade create event set the path variable to -1 so you don't get any issues later with uninitialized variables.
Okay I'll try that , Thanks
 
W

Wild_West

Guest
Have a controller object and in that set alarm[0] to one step. In the alarm 0 event of the controller, set the paths for the grenades. For example:

Code:
// CONTROLLER OBJECT CREATE
alarm[0] = 1;

// ALARM[0]  EVENT
with (obj_Grenade)
{
path = choose(path1, path2, path3);
path_start(path);
// or whatever...
}
In the grenade create event set the path variable to -1 so you don't get any issues later with uninitialized variables.

Works great :) I owe ya one
 
Top