Questions about PulleyJoint

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
LEVR
Prole
Posts: 3
Joined: Tue Jul 28, 2020 9:31 pm

Questions about PulleyJoint

Post 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!
Attachments
pulleyJointTest.love
(1.35 KiB) Downloaded 117 times
User avatar
pgimeno
Party member
Posts: 3640
Joined: Sun Oct 18, 2015 2:58 pm

Re: Questions about PulleyJoint

Post 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.
LEVR
Prole
Posts: 3
Joined: Tue Jul 28, 2020 9:31 pm

Re: Questions about PulleyJoint

Post 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?
User avatar
pgimeno
Party member
Posts: 3640
Joined: Sun Oct 18, 2015 2:58 pm

Re: Questions about PulleyJoint

Post 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.
LEVR
Prole
Posts: 3
Joined: Tue Jul 28, 2020 9:31 pm

Re: Questions about PulleyJoint

Post by LEVR »

Thank you!
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], IsraelSX and 3 guests