Welding bodies together becomes unstable
Posted: Mon Aug 15, 2011 9:20 am
I'm building a space-ship game, where you can continously attach and remove all kinds of modules to your ship. This is how a ship looks like right now: http://i.imgur.com/iQbo1.jpg. You can see the shapes and constraints.
The player can freely add more modules, like thrusters. However, if you add too much modules, things somehow start to shake violently when an impulse is applied. The structure becomes more volatile, the more modules are attached, sometimes getting so severe that modules get twisted out of place. Here are some images demonstrating this
I currently have each module connected like this:
This works by pushing the modules together, so they are bound by the constraints as well as collisions. I previously had only 2 joints positioned in a cross shape ( (0, 10) to (10, 0) and (0, -10), to (-10, 10) ), but because the modules can be mounted at different angles, this is not always a cross shape, allowing the modules to slide alongside their mount points.
If I add more constraints, the structure becomes more volatile. But if I remove constraints, the modules can move too freely, sliding alongside their mount points. I just want to 'weld' the modules together.
Any ideas how to fix this? Thank you in advance.
The player can freely add more modules, like thrusters. However, if you add too much modules, things somehow start to shake violently when an impulse is applied. The structure becomes more volatile, the more modules are attached, sometimes getting so severe that modules get twisted out of place. Here are some images demonstrating this
I currently have each module connected like this:
Code: Select all
PinJoint.new(anchr_a.shape.body, anchr_b.shape.body, Vec2.new(0, 0), Vec2.new(10, 0))
PinJoint.new(anchr_a.shape.body, anchr_b.shape.body, Vec2.new(10, 0), Vec2.new(0, 0))
PinJoint.new(anchr_a.shape.body, anchr_b.shape.body, Vec2.new(0, 0), Vec2.new(0, 10))
If I add more constraints, the structure becomes more volatile. But if I remove constraints, the modules can move too freely, sliding alongside their mount points. I just want to 'weld' the modules together.
Any ideas how to fix this? Thank you in advance.