yes, if you are referring to the original way.
I started with the ball and string example and have been editing the events from it.
yes, if you are referring to the original way.
I started with the ball and string example and have been editing the events from it.
This has got me puzzled - the line won’t draw/appear when you’re using the nearest object, yet it will draw if it’s put in an event that is run at the beginning of the scene.
Would you mind zipping up the project folder and sharing it so we can spot where it’s not working?
Sure. Thanks for spending so much time helping me. I am completely stuck.
The actions that are disabled are the ones that were in the original file that create the link. If you want to take a look at the whole thing with those not disabled to see why that’s not working either (anymore), please feel free.
I am assuming it’s because it is connected to the line drawing method originally used with it. But I think while trying to new methods of drawing, I broke the swinging aspect with the joint.
Here is the link to the file:
Your images are rather large - most SwingBoxes are over 200 pixels in size, so checking that the touch is within 50 pixels means the touch has to be on a SwingBox. As a result, no boxes were selected, and the rope never drawn.
Also, my logic wasn’t quite right - the rope drawing needed to be done every frame, not as a one off action.
I’ve fixed a few things - added a couple of scene variables, modified the rope settings and updated the logic. I also changed it from touch to mouse - it’s possible for a single touche to be referred to using the mouse functions in GDevelop. Also, there is a Rope shape painter already on the scene - leave it in.
These changes got it swinging and drawing the rope :
[edit] Here’s the rope joint settings :
Thank you for doing all of that.
I will try to figure out how to impliment what you did, and let you know how it goes.
I believe I was able to correctly do what you suggested, but it is still not drawing the rope.
It does let me click on a swing box and create the swinging behaviour, but it won’t disconnect nor connect to another swingbox when clicked anywhere else.
Also, it seems to attach itself and then swing on a specific swingbox even when I don’t click on that one.
Can you screen shot your events?
MouseX() and MouseY() don’t take any parameters. Remove the 0.
Thank you.
It’s still not drawing the rope, and when I click on nothing, it does not detach the swinging.
Can you screen shot your events again (to confirm the changes are correct.)?
The two reasons I can see for the rope not being drawn is that either the ropeJoint is not getting set, or you don’t have a Rope ShapePainter object on the scene. Can you double click the “Add a rope joint…” action, and confirm the settings are as in the image below, in particular the ropeJoint variable as shown in the bottom? If it’s not, then set it.
If it looks the same, then confirm you have a Rope ShapePainter on the scene? To do this in the editor, open up the list of instances, and search for Rope. The icon for this is at the top right of the editor :
If that shows a Rope object, then can you run the game in debug mode and confirm ropeJoint is being set? To get there, click on debug button at the top left of GDevelop and choose “Start Preview with Debugger…”
The game will start as per normal, but GDevelop will have an extra tab open up.
In the game preview, get MainChar to swing on a SwingBox. Once you’ve done that, go into GDevelop and on the debug tab click refresh. Then click on Scene Variables (4th item down) and in the panel on the right check on the value of ropeJoint. It should have a value of something other than -1.
I did not realize that I didn’t have ropejoint listed in that variable slot at the end. Once I added it, the rope does draw.
It now when I click on another swing box it does switch to that, but the movement of the ball (mainchar) is odd. Also when I click on space not near a swingbox, the rope goes away, but the ball is still swinging as if the rope is still there.
When you are removing a joint, make sure you select the object on which the joint was created. If you created it on the SwingBox, remove it from the SwingBox. Likewise, if it was created on MainChar, then remove it from MainChar.
To work out which object it was created on, double click on the “Create rope joint…” action, and see which object is highlighted on the left hand panel. This is the object to use for the remove joint action.
That was it!!! Thank you!
Just going to chime in here, MouseX()/MouseY() take layer and camera # parameters, just like camera (since it’s detecting mouse touch on a layer), and I usually recommend they get propagated in full if doing anything with specific layers. Otherwise they default to base layer.
(Camera number is legacy and can always be left as 0, but MouseX(0) means nothing, it’d have to be MouseX(“”,0) to be anything.)