Greetings Lövers,
I've been trying to do a proper love.physics rope(not RopeJoint but a real rope) for some time now and still can't get it right.
I've already read several threads about this here, but none of them really helped me. Since they aren't about my main issue:
No matter what Joints I use (tried distance and ropeJoints) the first rope bodies will always act like they're elastic and lengthen if the force applied to it by the main body is too high.
A picture will make this clearer I think:
As you maybe already saw here, not only the first Joint is being stretched, but also all the following ones, though the stretch isn't that obvious there.
(Note, that the the joint between body 1(in the center of the outlined circle) would also be stretched, but is is positioned each update at the center again to work against this)
Setting the mass to zero does not work sadly, and I can't think of any other way to work around this problem.
Use the left mouse button in the attached .love to create a circle and a rope between the ball on the ground.
Thanks in advance for any help <3
A proper Rope
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
A proper Rope
- Attachments
-
- physic.love
- (3.01 KiB) Downloaded 231 times
Re: A proper Rope
I remember someone else asking a similiar or the same thing.
viewtopic.php?f=4&t=7689
I didn't look further into it after that.
viewtopic.php?f=4&t=7689
I didn't look further into it after that.
Shallow indentations.
Re: A proper Rope
Yeah, I already read it, but he hasn't a solution either.Boolsheet wrote:I remember someone else asking a similiar or the same thing.
viewtopic.php?f=4&t=7689
I didn't look further into it after that.
And the weird thing is, that this decreasing of the stability of joinst due to a too high mass ratio, isn't the problem since it doesn't work with all masses(but the main body) at zero.
Re: A proper Rope
I don't know Box2D that well, but there are some things that caught my attention.
Setting the mass of a dynamic body to 0 (or lower) sets the body mass to 1. This is hardcoded into Box2D.
Don't set the body position every update. It seems to confuse Box2D and the simulation falls apart. The mouse joint can be used to have a body follow a certain position, but it was designed for the testbed and may not fit into your usecase. The manual mentions kinematic bodies, but I don't know how that would look like. Using its velocity to follow the mouse maybe...
I guess only a higher step count would increase the stability more.
Setting the mass of a dynamic body to 0 (or lower) sets the body mass to 1. This is hardcoded into Box2D.
Don't set the body position every update. It seems to confuse Box2D and the simulation falls apart. The mouse joint can be used to have a body follow a certain position, but it was designed for the testbed and may not fit into your usecase. The manual mentions kinematic bodies, but I don't know how that would look like. Using its velocity to follow the mouse maybe...
I guess only a higher step count would increase the stability more.
Shallow indentations.
Re: A proper Rope
If I won't force the body position of both the main body and the first rope body to a specified position, the whole rope goes crazy and seems to just fall down. The same with MouseJoints.Boolsheet wrote:I don't know Box2D that well, but there are some things that caught my attention.
Setting the mass of a dynamic body to 0 (or lower) sets the body mass to 1. This is hardcoded into Box2D.
Don't set the body position every update. It seems to confuse Box2D and the simulation falls apart. The mouse joint can be used to have a body follow a certain position, but it was designed for the testbed and may not fit into your usecase. The manual mentions kinematic bodies, but I don't know how that would look like. Using its velocity to follow the mouse maybe...
I guess only a higher step count would increase the stability more.
Isn't there a way to just force box2d to maintain a fixed length between the bodies, no matter what?
Re: A proper Rope
"Isn't there a way to just force box2d to maintain a fixed length between the bodies, no matter what?"
u could just "teleport" the bodys every frame, i think u'll quickly find why the box2d doesnt do this
i would try limiting to max speed of the ball locked to the mouse or up'ing the step count when ever the distance of the joints go above 105% of what it should be
edit//
u REALLY need to comment ur code, but that said adding these two parts of code did nearly fix the problem
and both are really hamfisted fixes that im sure u can improve on
u could just "teleport" the bodys every frame, i think u'll quickly find why the box2d doesnt do this
i would try limiting to max speed of the ball locked to the mouse or up'ing the step count when ever the distance of the joints go above 105% of what it should be
edit//
u REALLY need to comment ur code, but that said adding these two parts of code did nearly fix the problem
Code: Select all
world:update(dt/3)
world:update(dt/3)
world:update(dt/3)
Code: Select all
speedreduction=3
newx =bodyX+xdist/speedreduction --TODO replace w/ better math
newy =bodyY+ydist/speedreduction
lastbody:setPosition(newx,newy)
Re: A proper Rope
If you increase the value of setMeter to a higher value...say 500, the problem seems to be less evident..hope this helps
wat ya mean she's in another castle!?
Re: A proper Rope
That bit of code actually really helped, when using 12+ segments it still gets worse, but not as much as when not using your code, thanks for that <3monkyyy wrote:Code: Select all
world:update(dt/3) world:update(dt/3) world:update(dt/3)
The second one did also work quite well, but I rather stay with using the linearVelocity since it makes the movements quite more lövely.
Increasing the setMeter value actually helps, but also makes movements really unrealistic and fast, so thats no real option >:juno wrote:If you increase the value of setMeter to a higher value...say 500, the problem seems to be less evident..hope this helps
But thanks anyway!
Re: A proper Rope
i would not use that code unmodified, like i said, it needs to be improved on, it wont scale at all, and would probably be completely worthless at 15+ seg'sAlex22 wrote: That bit of code actually really helped, when using 12+ segments it still gets worse, but not as much as when not using your code, thanks for that <3
something like
Code: Select all
if"this code needed"
then magicly get a x value on how much it is needed
loop " world:update(dt/x)" x times
end
Who is online
Users browsing this forum: Bing [Bot] and 4 guests