There isn’t a way to make a path in the editor, but as one possible solution you could place a bunch of sprite instances along a path and use that.
Create a sprite and call it “node.” Give it and instance variable called “order.”
Now just make multiple instances of node and position them in the shape of the path you want. Then set the order variables for each instance. 1 for the start, 2 for the second and so on. This is so we can move along them in order.
Next we need to setup the object that will move along the path. Create a sprite and call it “follower.” Give it some instance variables:
pos=0 for it’s position on the path
speed=10 for the speed along the path.
Anyways on to the events to make follower to move back and forth along the nodes:
Every tick
— follower: add self.speed*dt to pos
Follower: pos<0
— follower: set pos to 0
— follower: set speed to -self.speed
Follower: pos>node.count-1
— follower: set pos to node.count-1
— follower: set speed to -self.speed
Global number t=0
Global number id1=0
Global number id2=0
For each node ordered by node.order ascending
— follower: pos<=loopindex
—— set id1 to node.iid
— follower: pos>=loopindex
—— set id2 to node.iid
——stop loop
Every tick
— set t to follower.pos-int(follower.pos)
— follower: set x to lerp(node(id1).x, node(id2).x, t)
— follower: set y to lerp(node(id1).y, node(id2).y, t)
That will change the followers pos variable with the speed. If it goes off either end then the speed is reversed and the pos is limited to the end.
Next we loop over the nodes to find the instance right before and right after the object’s current pos.
Finally we use lerp to get an actual xy position between those nodes.
Note:
Speed is how fast the follower moves from node to node. So for consistent speed keep the nodes evenly spaced.
The events were done with only one path and one follower in mind.
Barring any typos the above should work.