[SOLVED] Shape painter proper positioning while stuck on a draggable object

Hey everyone.

I have some object markers stuck (behavior) on a map, the map itself can be dragged around, on that map I’ve added shape painters (also stuck on the map) to draw circles and a path where the player can travel along.

However, whenever I start dragging the map around the shape painters don’t seem to follow their positioning very well. looks kinda glitchy.

2024-11-09 22-33-03_2

Is there a way to fix that somehow?
Thanks

Hi TFMSTYLE

Can you post a screenshot of the events that draw and position things? It might be an order issue. It might be using old coordinates or move something after something else.

Hey Keith, yep sure.

These are the events I have to draw these lines/Circles.
They get stick to the map at scene begin.
Apart from that, they don’t get mentioned elsewhere.

I’m not clear on your whole method like the markers.
I tried adding dragable markers that I name nodes.

The first time, I drew on the shape painter using the screen coordinates and the shape painter lagged when dragged. When I checked the draw relative checkbox, it seemed to work. I had to subtract the position of the shape painter.

My events

Try me (the graphics are crude. You can drag the map or nodes)
https://gd.games/instant-builds/1fe7d337-51ec-4ed9-87ab-f45869396b07

I don’t know what causes the lag. I’m guessing timing between the drag and the shape painter. IDK. Maybe, it redrew and then moved. IDK. It seemed to use old coordinates like from the previous frame.

Thanks for the info and little demo, yeah yours looks right!
I might need to redo my setup to see what’s wrong.

Cheers.

1 Like

Yeah I had to subtract the position of the shape painters, it works now properly.

However from what I’ve tried, you can’t do the same with objects using the Pathfinding and DrawPathfinding behaviors…

They do need a shape painter object to draw the path, but you can’t subtract it’s position.

If you have any workaround for that, let me know.
Cheers and thanks again.

You could modify the pathfinder draw extension or use your own events.

You can use a counter to go through the nodes. You repeat one less than the node count because it draws a line from node # to node # +1

A larger view of the line draw action

Nice, I didn’t know you could do that in the events, I was trying to change that directly in the extension.

This did help, however there’s still some lag when dragging while the Path has been draw. and I have no idea why.
This is my setup so far.

I’m drawing the Path, put the player speed and acceleration to 0. and the player moves on the path only when i press the travel button.

Last night, I didn’t try moving the path with the map. It went crazy for me. I removed the -shapePainter x and y from the node locations and it worked. The key is to place the shape painter where you want it to be drawn.

I don’t know your goal but my path was huge. It was full size. I placed the shape painter in the corner of my map and divided the location by 10. Although, that seemed to small. Instead if a fixed number maybe it needs to be calculated.

Again, I’m not sure about your goal. If you want to add clickable nodes then you could create the node or markers while you draw the path.

If this is your intention then this is a hybrid of the 2 process. You might need to set the speed to 0. The placement of the shape painter that draws the map might also need to be dynamically placed like at one of the node locations or maybe an average or something. IDK. I’m starting to make guesses.

The mouse event was just used for testing. Your conditions will probably vary.

1 Like

Hey, thanks for putting so much thought into it. Still trying to figure it out, I will try the hybrid method. to create the node on the marker instead of trying to move the one I placed, might be the issue to be honest, cause so far even the moving was acting a bit weird.

Will let you know tho.
Thanks for the tips.

1 Like

You’re welcome. I like to help. I also enjoy the challenge. Just a tip. When you delete the marker or any other object never add the new objects as a subevents of the delete. Weird things happen. Always make the events separate not subevents.

1 Like

Alright, finally made it work properly. It was an ordering issue, the move player action needed to be before to draw path. I used to have it in a sub event after drawing the path, and that caused issues with the path positioning I think.

There’s still one issue that I don’t know how to fix. If I drag the map While the player is moving along the path, the player position doesn’t follow the path, it gets offsetted by the drag. Have no idea how to fix that, I tried to offset it back but it doesn’t seem to work, even when the player is Stuck to the map.

If you have some inputs or things I could try let me know.
Otherwise thanks for all your inputs!
Been following the forum for about a month now, there’s a couple names like yours that i keep seeing with good answers! Good stuff.

Cheers.

If the path doesn’t move with the map them make sure the shape painter is set to relative

image

You may need to control an offset or make sure the shape painter is placed in the right spot when the sticker is applied. the shape painter should probably always start at 0,0 for the corner of the view. Whether you need to subtact an offset or camera postion depends on the rest of the game.

1 Like

Hey Keith,

No the shape painter is properly placed even when i drag the map around, I fixed that. the issue is when the player moves along that path and the map gets dragged the Player gets offsetted from the path!

2024-11-12 13-15-05_2

The black line is the path, traced by the player behavior using a shape painter.
the player moving is the red cross.

Is the red object the player or a sprite that represents the player?

Either way, if it’s moving by the pathfinder there’s no way to offset the path once it starts unless you hid the object and created a copy that used it for reference plus/minus an offset.

Maybe put the object on its own layer and change its camera based on the dragable object position .

The red object is a sprite that represents the player, that has the path behavior.
For now i’m just disabling the drag behavior when the player moves, i might leave it this way, since it works fine in this case.

But i wanted to mention it, cause it’s weird, the path is drawed by the player object, shouldn’t the path dictate the player position by default?

both the player and the path are stuck to the map, but as soon as the player moves, then its acting on its own.

If the player is moving then it can’t or shouldn’t be stuck. I would put the object on its own layer and change the layers position in relationship to the dragable object.

Maybe, we’re over thinking this whole thing. Maybe put everything on its own layer and just make the camera for that layer dragable. There’s be an extension.

I added the extension and a dragable object on the base scene with the other object on a layer name layer


The dragable object could be a title bar, background or the size of the map but hidden.

Using a separate layer would allow the map to be resized by changing the layer zoom level.

You could also move the map to a custom object and then drag the custom object.

oh i see, that smart, makes more sense to have the map at a fixed location and just drag the camera around, wouldn’t have issues with the objects positions.

Will try that out! thanks again!

Works pretty well now.

2024-11-12 18-07-23_3

Putting all this into another layer made the whole setup easier!
Cheers

1 Like