Quick help with physics.RopeJoint

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
eyeck
Prole
Posts: 6
Joined: Mon Apr 16, 2012 4:55 pm

Quick help with physics.RopeJoint

Post by eyeck » Mon Apr 16, 2012 5:05 pm

I've just started working with Box2d as opposed to rolling my own physics engine and I've run into a slight problem. I'd like to use the RopeJoint class, but I can't figure out what to pass for x1, y1, x2, y2, or maxLength as arguments to love.physics.newRopeJoint. Are x1, x2, etc. in local or world coordinates? Is ( x1, y1 ) the position of the anchor on body1? is maxLength in "pixels" or meters? I've been trying everything I can think of but I can't seem to get a functional RopeJoint. A more detailed explanation of the arguments would be hugely appreciated, or a simple working demo would be even better if anyone is willing to take the time. Thank you!

iemfi
Citizen
Posts: 52
Joined: Fri Mar 30, 2012 11:03 am

Re: Quick help with physics.RopeJoint

Post by iemfi » Mon Apr 16, 2012 5:10 pm

Unless it's different from a distancejoint the coordinates are world coordinates and the maxlength is in pixels.

eyeck
Prole
Posts: 6
Joined: Mon Apr 16, 2012 4:55 pm

Re: Quick help with physics.RopeJoint

Post by eyeck » Mon Apr 16, 2012 5:13 pm

Thanks for the reply. That didn't seem to work when I tried it that way, so I must be doing something else wrong. When I get home from work soon I'll post a quick example of what I tried.

User avatar
The Burrito
Party member
Posts: 153
Joined: Mon Sep 21, 2009 12:14 am
Contact:

Re: Quick help with physics.RopeJoint

Post by The Burrito » Mon Apr 16, 2012 5:53 pm

This is 0.8.0 right? I had a working rope joint demo in January but I just tried to load it up and the rope segments fall away as if they aren't connected. When I had it working it looks like I was using local points, which would make more sense IMO but I feel like they're supposed to be world coordinates. The first coord is the anchor for the first body, second for second body. Pretty sure everything is in pixels now.

The only update since then that would've affected ropes directly that I can see is this: https://bitbucket.org/rude/love/changeset/2f56e709d4d1
But a lot of tweaks and fixes were made in February so it could have something to do with the fixtures / bodies themselves and not the joints.

I'm curious about this too, ropes are a lot of fun.

eyeck
Prole
Posts: 6
Joined: Mon Apr 16, 2012 4:55 pm

Re: Quick help with physics.RopeJoint

Post by eyeck » Mon Apr 16, 2012 7:15 pm

Yep, 0.8.0. I'm experienceing what you describe, however depending on what I set maxLength to sometimes weird glitches will occur (such as the objects teleporting around and suddenly changing velocity. Certainly not what you'd expect from a ropeJoint i.e. ).

I have attached a simple .love:
joints.love
(736 Bytes) Downloaded 237 times
which shows a DistanceJoint working as expected, a RopeJoint using nearly identical data yet behaving much differently, and the same objects without any joint at all (might as well be scientific :megagrin: ). On both Linux and Windows with Love 0.8.0 it appears to behave identically. Any idea what is causing the unexpected behavior from the RopeJoint?

iemfi
Citizen
Posts: 52
Joined: Fri Mar 30, 2012 11:03 am

Re: Quick help with physics.RopeJoint

Post by iemfi » Mon Apr 16, 2012 8:57 pm

Ooh, apparently the x1,y1,x2,y2 coordinates are scaled twice or something (bug?)? I multiplied all the coordinates except the maxDistance by the value of setMeter and it works! Science!

eyeck
Prole
Posts: 6
Joined: Mon Apr 16, 2012 4:55 pm

Re: Quick help with physics.RopeJoint

Post by eyeck » Mon Apr 16, 2012 9:41 pm

Yep, looks like that's it! Interesting, in the changeset The Burrito posted, it seems that the signature for Physics::scaleDown changed from accepting a b2Vec2 to accepting two seperate ints; maybe the bug was introduced somewhere in that change? Wonder if this is affecting any other love.physics functions?

And now, I get to make the lovely (no pun intended) decision between a) adjusting for the bug and having my code break at an unspecified point in the future and b) simply not using any RopeJoints until the next release...

iemfi
Citizen
Posts: 52
Joined: Fri Mar 30, 2012 11:03 am

Re: Quick help with physics.RopeJoint

Post by iemfi » Mon Apr 16, 2012 10:18 pm

I used 2 distance joints instead for my project before love 0.8, functions the same and you can always add more if you want the rope to look prettier.

Post Reply

Who is online

Users browsing this forum: Google [Bot], HDPLocust and 29 guests