I have two different, but probably related, problems. Basically, I'm trying to replicate the system used in the game "Hammerfight," where you have weapons spin around a central axis (your ship).
The first problem is that when I create a "chain" of sorts out of rectangles and revolutejoints, and then I spin this system around, the chain links start stretching out. I would like them to stay connected to each other, end to end. The problem becomes more pronounced the more links there are in the chain.
The second is that when I create a rod attached to the "ship," and then I collide the rod into a wall, not only does it go through the ship, but when I stop forcing the rod down it acts like a pogo stick, propelling the ship. When the rod hits the wall, the system of the ship and the rod should simply stop.
Hopefully you can help! Two love files are attached, demonstrating the two problems. To move the "ship," the circle, click and hold the left mouse button. To see the chain stretching problem, click and hold the LMB and move it around in a circle, around the ship. To see the rod problem, collide the end of the rod into a wall.
RevoluteJoint stretching
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
RevoluteJoint stretching
- Attachments
-
- Physics Rod.love
- Demonstrates the rod problem
- (1.63 KiB) Downloaded 128 times
-
- Physics Chain.love
- Demonstrates the chain stretching out
- (2.23 KiB) Downloaded 143 times
Re: RevoluteJoint stretching
Hi there.
I tried running your demos, but I was getting an error message do something like
This way the physics engine will have smaller errors to correct each time the update is done. It will probably cost you more cpu cycles each frame, but should improve the accuracy of simulation.
I don't guarantee it will work, but it's certainly worth a shot. If you try this, let me know if it worked.
Funny thing - I also tried to make a game like Hammerfight, but that was before I knew that Hammerfight exists
I tried running your demos, but I was getting an error message
I think I know what's your problem though, as I have encountered the behaviour you describe. I haven't tried it myself, but I think that running the physics simulation more often and with smaller time step may help. Let's say, on each frame, instead of doing justlove: modules/physics/box2d/Source/Collision/Shapes/b2PolygonShape.cpp:224: b2PolygonShape::b2PolygonShape(const b2ShapeDef*): Assertion `d.x >= 0.0f' failed.
Code: Select all
world:update(dt)
Code: Select all
for i = 1, 4 do world:update(dt/4) end
I don't guarantee it will work, but it's certainly worth a shot. If you try this, let me know if it worked.
Funny thing - I also tried to make a game like Hammerfight, but that was before I knew that Hammerfight exists
- tentus
- Inner party member
- Posts: 1060
- Joined: Sun Oct 31, 2010 7:56 pm
- Location: Appalachia
- Contact:
Re: RevoluteJoint stretching
Don't do this, it won't help.Rad3k wrote:Hi there.
I think I know what's your problem though, as I have encountered the behaviour you describe. I haven't tried it myself, but I think that running the physics simulation more often and with smaller time step may help. Let's say, on each frame, instead of doing justdo something likeCode: Select all
world:update(dt)
Code: Select all
for i = 1, 4 do world:update(dt/4) end
I was able to replicate your problem, though it wasn't terribly visible. Try cleaning up your code a little and maybe you'll spot the error. You've got some conflicting comments and such ("gravity will be 80" when it is 50). Also, is it just me or does the chain tend to "knot"?
Kurosuke needs beta testers
Who is online
Users browsing this forum: Google [Bot] and 0 guests