Line-following on touchscreen

I am trying to make a game similar to ‘Harbor Master’ on iPhone, and I am wondering if anyone knows of an extension that allows the player to select an object and draw a line which is the followed by the object.

Now I have been using the extension “drawPathfinding”, but that just seems to create a ‘wake’ after the object. What I am looking for is the opposite.

That is pretty interesting, I have never heard of that game but to me this almost seems like how you direct movement in an RTS style game. Currently I am very new to this engine, but I think the tower defense game example might be able to point you in the right direction.

If I remember correctly those guys march to points in a path but the points are made invisible. Perhaps making a tiled sprite for your line that then stretches to the next point would work? I haven’t utilized drawPathfinding yet so unfortunately I can’t help much there. In my brain, we would have an event that whenever whatever you wanted to follow the path reached the destination we remove the path and prepare for the next one.

Hopefully we’ll get some more interactions on this post for you and we’ll get this answered!

Spent the day trying to replicate this video: https://youtu.be/0QyGrcN3Z8o

It should have brought me in the right direction, but I am unable to make my object follow the path (it just moves upwards and out of the screen). Some of the names for conditions and actions have changed in Gdevelop since the video was made, but I am pretty sure that I have replicated it correctly…

Great input!
I am checking out the code, which makes objects follow a preset path between points. I basically want to do the same thing, but between points in a line that has been drawn by the user.

Ps. I found a video of Harbor Master

1 Like

Can you screen snip the events you have at the moment? We can have a look at it an see if we can spot the mistake.

I see 2 techniques.

I didn’t watch the whole video bc I’m on my phone but it seems to place an object while the mouse/touch is down as long as it’s a certain distance from the last point. The new object would need at least 2 variables the ID of the ship and a counter. When the mouse was released the object would move toward each object that was just placed in order of their counter using matching IDs. When it either collided with the objects then it would be deleted and it would repeat toward the next object. You could move the ship with a permanent force and when it ran out of points it would just continue on it’s last direction.

Another method would be instead of objects add the points to an object array. You could then either tween from point to point or use the distance to the next point or use 1 object as a target. Place the object on the next point, add a permanent force toward it and then move it to the next point when it collides with it and repeat until the last point and then delete it.

Great suggestions Keith - thx. This is what I’ve come up with so far, which seems like a combo of your two methods…

You’re welcome. Does it work so far?