我试图使用棱柱关节在box2d中创建一个移动平台,所创建的只是一个盒子并且没有明显的关节,我做错了什么?这是我的代码
var prismaticJoint:b2PrismaticJoint;
...
{
...
BodyDef.position.Set(0 / RATIO, 0 / RATIO);
floorDef.SetAsBox(250 / RATIO, 10 / RATIO);
fixtureDef.shape = floorDef;
fixtureDef.friction = 0.5;
fixtureDef.density = 0.5;
fixtureDef.restitution = 0;
movePlatformBody = PhysiVals.world.CreateBody(BodyDef);
movePlatformBody.CreateFixture(fixtureDef);
var prismaticJointDef:b2PrismaticJointDef = new b2PrismaticJointDef();
prismaticJointDef.Initialize(body, movePlatformBody, movePlatformBody.GetWorldCenter(), new b2Vec2(0,1));
prismaticJointDef.enableLimit = true;
prismaticJointDef.enableMotor = true;
prismaticJointDef.lowerTranslation = 0;
prismaticJointDef.maxMotorForce = 100;
prismaticJointDef.motorSpeed = 1;
prismaticJointDef.upperTranslation = 270 / PhysiVals.RATIO;
PhysiVals.world.CreateJoint(prismaticJointDef);
//prismaticJoint = PhysiVals.world.CreateJoint(prismaticJointDef as b2JointDef) as b2PrismaticJoint;
我尝试了两种在世界上创建它的方法,我不知道该使用哪一种。如何在 box2d 中创建移动平台?感谢您抽出时间来阅读。