If I create multiple instances of an object that use the physics engine, how can I connect the instances to each other with joints?
Since they all have the same name but different ID (object variable) I cant find a way to connect them with joints. Joints only seem to use object names to connect ot each other. I am trying to create a fishing net, as in the image below, but a much bigger net, that moves naturally in the water.
I guess I need to create both instances before I can connect them. After doing that I would need to reference them using their object name and object variable. But I can’t figure out how to write an expression that use the object variable. The only parameters I can find are the points of the original object.
I’m calling the object that represents the net thread points a connector.
Give each connector an increasing ID from left to right, top to bottom (so top row from left to right is 0, 1, 2, 3…n, second row is n+1, n+2, n+3 etc)
Then run 2 loops - one for horizontal connectors, the second for vertical connectors. Something along the lines of this (I’ve assumed 6 columns with 4 rows of connectors based on the image in your first post) :
Wow, thanks so much for helping me out!!
For some reason I’m bad at understanding screenshots of event sheets so I hope I’ll manage to figure out what you have done. Anyways, this will help me forward. Thanks again!
Hi again MrMen,
First question. The first event where you create the variables seem to be repeated. I guess there is a missing “At the beginning of scene”?
Second, you have made a “Repeat Variable(colCount) times:”
-How do you do that? The only repeat I can create is “repeat for each instance” where I have choose an object. Not a variable.
Also you have made a “Repeat Variable(rowCount)- 1 times:”
-What does that mean? Repeating one time is like not repeating at all. Also, the minus (-) makes it negative. Repeating negative times makes no sense to me. I just don’t understand what the code is doing and I don’t know how to create it.
You’re creating the netLine and netLIne2 objects at 600,700. They need to be in their correct position before you add the rope joints. Otherwise GDevelop will try to maintain a rope distance of 0 pixels.
Also, what you will probably get is that the net folds in on itself. You may need some type of force or joint that causes the bottom left and bottom right netLines to go out and down further, to keep the tension on the net and keep it spread out.
Imagine it like a sheet of cling-wrap plastic that’s just been taken off the roll. You need to pull it apart to get it into it’s shape again. The same has to be done here with the netLine connections.
That complicates things even more. Maybe I can use the “Create multiple copies of an object” extension, since it creates objects in a grid and also seems to create IDs for the instances. Actually I feel that I’m a bit over my head with this. I can’t even create the IDs of the instances. Maybe I should create a separate question about that, since it’s such a basic issue.