(Solved) Drag objects using a line (shape painter)

Hello everyone! I am trying to draw a line between two objects, kinda like connect the dots type. And, I want the object its connected to be draggable only when the lines are attached to the object.

Here’s the visualization of what I’m trying to accomplish:

I’m having a hard time for days figuring out how these lines connect with the other object and then having draggable behavior activate when they’re connected. If anyone could lend their idea on how to execute this I would really appreciate it. Thank you so much.

How are the lines going to be connected? From the square to the other objects? Are they going to be interconnected? How do the smaller objects get placed?

I might use linking to link objects and draw lines between linked objects . Either check if there are any links or use a Boolean variable as a state. I prefer to use states. If they’re interlinked then you would need a second object for each object to handle linking between the same object.

Or you could use arrays of either x, y locations or object IDs.

It all depends on how the objects are added and whether they’re moveable after they’re placed or the after lines are added. And which objects can have lines and if they could have multiple lines.

1 Like

Hello Keith_1357. The lines will be drawn from the box to the little fire thingy.

It’s still vague. If you use a Boolean on the object then you can toggle the value or set it to true/false.

Try me: Left mouse drags, right mouse clicks toggle it on and off. I used the opposite mouse button so it didn’t interfere with the mouse drag.

It uses one object variable for the gun called Linked a Boolean. Both options are unchecked in the shape painter.

Do you want to link the “guns” to other “guns”?

1 Like

I apologize if it’s vague.

What I was meant was that I wanted to draw a line from the box to the circle and make that line attach between them. I wish to do that to the other circles too. And, when the lines are attached the circles they then become draggable.

I wish to make a game like that on my phone. I can’t seem to play what you made on my phone, I’ll try it on my computer later, but thank you so much for showing me your solution. I really appreciate it.

1 Like

Keith_1357, I just played what you did, it’s exactly how I wanted it. Thank you so much!


But I can’t seem to clear this one line after clicking the right mouse. But, I’ll try and figure it out. Thank you again so much for your help!

I figured out (kinda) how to attach the lines to my object but it goes invisible when I release touch.


Release touch:

Here’s how I did it based on you work:

Did you unclick the “clear image between frames” (or whatever it’s called) for the shape painter?

1 Like

I just did and it worked :grin:

but I still can seem to clear this single line. There’s always one line left when I try to remove all lines by tapping/clicking.

I don’t know why but even in my example, the clear shapes action is after the select all, linked is true. As is, at least 1 object would have to be set to true for it to clear rendered image. I think the clear action just needs to be moved up an event before that.

1 Like

I can’t thank you enough :sob: You are the best! Thank you so much!

1 Like