It looks like you're new here. If you want to get involved, click one of these buttons!
require("box2d") world=b2.World.new(0,0) w=320 h=480 length0=100 atom1=world:createBody({type=b2.DYNAMIC_BODY, position={x=w/2,y=h/2}, linearVelocity={x=0,y=-50}}) atom2=world:createBody({type=b2.DYNAMIC_BODY, position={x=w/2,y=h/2+length0}, linearVelocity={x=0,y=50}}) shape=b2.CircleShape.new(0,0,20) atom1:createFixture({shape=shape}) atom2:createFixture({shape=shape}) jointDef={type=b2.DISTANCE_JOINT, bodyA=atom1, bodyB=atom2, localAnchorA={x=0,y=0}, localAnchorB={x=0,y=0}, length=length0} jointDef.frequencyHz=5 jointDef.dampingRatio=0 -- should be frinctionless jointDef.collideConnected=false joint=world:createJoint(jointDef) local debugDraw = b2.DebugDraw.new() world:setDebugDraw(debugDraw) debugDraw:setFlags(b2.DebugDraw.SHAPE_BIT + b2.DebugDraw.JOINT_BIT) stage:addChild(debugDraw) function update() world:step(1/60,8,3) end stage:addEventListener(Event.ENTER_FRAME, update) |
Comments
By box2d docs, it's a The mass-spring-damper frequency in Hertz.
As in it's a damper frequency and not (here comes the physics term) jumping frequency.
I currently don't know if something like that can be achieved by joints only, but it should be possible by either adjusting restitution of objects (if they can collide), or controlling their linear velocity
http://www.box2d.org/forum/viewtopic.php?f=3&t=7017
It seems Box2d has an update algorithm which automatically adds friction to springs even ones the user specifies as having zero damping. In the above link there is PDF linked which gives more details. I'm a bit disappointed to be honest, I thought Box2d's output would be physically realistic. Catto's reason is the algorithm ensures stability but you also have to solve the correct physics!
But it occurred to me that now Catto knows the problem he may have fixed it. So what version of Box2D is Gideros running? Are you keeping up with new versions?
https://github.com/gideros/gideros
https://www.youtube.com/c/JohnBlackburn1975