Page 1 of 1

Questions about PulleyJoint

Posted: Tue Jul 28, 2020 10:03 pm
by LEVR
Hi, I'm new to Love2d, and I was trying to make a mechanic with a PulleyJoint and two rectangles that were restricted to move only along a y axis and not rotate. However, when I tested this, it completely broke. Even though one rectangle was twice as heavy, they wouldn't move. Am I understanding/implementing something wrong? I isolated the blocks and pulley and the same thing happens (attached). The actual project I'm using this for involves a system of resizing the counterweight block (and increasing its mass proportionally) under similar conditions, which will make the main block move slightly but only because the anchor point on the counterweight block changes. It eventually just inches back to equilibrium (the original positions), despite one block weighing almost 1000 times more than the other.
I can't attach the actual project because when I tried to make it into a .love file and running it, it returned errors about files. For some reason it runs just fine when unpacked with notepad++ and command line but can't find the files when it gets packaged into a love file.
Thank you in advance for your help!

Re: Questions about PulleyJoint

Posted: Wed Jul 29, 2020 1:14 am
by pgimeno
LEVR wrote: Tue Jul 28, 2020 10:03 pm Hi, I'm new to Love2d, and I was trying to make a mechanic with a PulleyJoint and two rectangles that were restricted to move only along a y axis and not rotate. However, when I tested this, it completely broke. Even though one rectangle was twice as heavy, they wouldn't move. Am I understanding/implementing something wrong?
In the example you've posted, one of the anchor points is wrong. This creates the pulley joint correctly:

Code: Select all

pulleyTest.pulley = love.physics.newPulleyJoint(pulleyTest.mainBody,pulleyTest.cw,0,-200,200,-200,0,0,200,0)
However, it's not liking the prismatic joints as you've written them. For some reason, changing the axis of the second joint to 0,-1 instead of 0,1 made it work for me, but I don't understand why.

LEVR wrote: Tue Jul 28, 2020 10:03 pm I can't attach the actual project because when I tried to make it into a .love file and running it, it returned errors about files. For some reason it runs just fine when unpacked with notepad++ and command line but can't find the files when it gets packaged into a love file.
Zip files are case-sensitive. Be careful to respect the case of all files in the code. That will also happen to Linux and BSD users.

Re: Questions about PulleyJoint

Posted: Wed Jul 29, 2020 1:57 pm
by LEVR
I see. I managed to get the correct result with your fixes as well, thank you very much! I'm guessing that all joints use world coordinates for anchors then? It didn't mention world or local on the wiki so I assumed local. Also, does the prismatic joint only allow movement in the direction of the axis vector and not the opposite direction? If so, is there any other joint that will allow movement in either direction on an axis?

Re: Questions about PulleyJoint

Posted: Wed Jul 29, 2020 3:43 pm
by pgimeno
LEVR wrote: Wed Jul 29, 2020 1:57 pm I see. I managed to get the correct result with your fixes as well, thank you very much! I'm guessing that all joints use world coordinates for anchors then?
Yes.
LEVR wrote: Wed Jul 29, 2020 1:57 pm Also, does the prismatic joint only allow movement in the direction of the axis vector and not the opposite direction? If so, is there any other joint that will allow movement in either direction on an axis?
I don't know, I assumed it would allow movement in both. I'm still puzzled about it.

Re: Questions about PulleyJoint

Posted: Wed Jul 29, 2020 7:50 pm
by LEVR
Thank you!