Hello every one
English is not my native language,it is too difficult to write a clear description, so forgive me please.
Box2D is so powerfully, but there is a small issue in my game development,
There is a "Elevator" to take "Robot" down or up in game.
I build "Elevator" with following code."Elevator" is static body.
var tShapeDef:b2PolygonDef = new b2PolygonDef()
tShapeDef.density = 0
tShapeDef.friction = 1
tShapeDef.vertexCount = 4
tShapeDef.vertices[0].Set(0, 0)
tShapeDef.vertices[1].Set(tRectange.width / 30, 0)
tShapeDef.vertices[2].Set(tRectange.width / 30, tRectange.height / 30)
tShapeDef.vertices[3].Set(0, tRectange.height / 30)
mBody.CreateShape(tShapeDef)
mBody.SetMassFromShapes()
And I move "Elevator" with following code.
mVector.x = x / 30
mVector.y = y / 30
mBody.SetXForm(mVector, 0)
When robot stand on "Elevator" and "Elevator" move up, every thing is OK.
When robot stand on "Elevator" and "Elevator" move down, the joints of robot don't work. Please look at screenshot.
I use "b2RevoluteJoint" to link wheel to body with following code
var tJointDef:b2RevoluteJointDef = new b2RevoluteJointDef()
tJointDef.Initialize(mMainBody, mWheelBodyB, mWheelBodyB.GetWorldCenter())
tJointDef.enableMotor = true
tJointDef.maxMotorTorque = 0
tJointDef.motorSpeed = 0
mWheelJointB = mBox2D.CreateJoint(tJointDef) as b2RevoluteJoint
I try to "SetLinearVelocity" to "b2RevoluteJoint", but nothing was changed
Any friends could told me why and how to do? many thanks to you!
English is not my native language,it is too difficult to write a clear description, so forgive me please.
Box2D is so powerfully, but there is a small issue in my game development,
There is a "Elevator" to take "Robot" down or up in game.
I build "Elevator" with following code."Elevator" is static body.
var tShapeDef:b2PolygonDef = new b2PolygonDef()
tShapeDef.density = 0
tShapeDef.friction = 1
tShapeDef.vertexCount = 4
tShapeDef.vertices[0].Set(0, 0)
tShapeDef.vertices[1].Set(tRectange.width / 30, 0)
tShapeDef.vertices[2].Set(tRectange.width / 30, tRectange.height / 30)
tShapeDef.vertices[3].Set(0, tRectange.height / 30)
mBody.CreateShape(tShapeDef)
mBody.SetMassFromShapes()
And I move "Elevator" with following code.
mVector.x = x / 30
mVector.y = y / 30
mBody.SetXForm(mVector, 0)
When robot stand on "Elevator" and "Elevator" move up, every thing is OK.
When robot stand on "Elevator" and "Elevator" move down, the joints of robot don't work. Please look at screenshot.
I use "b2RevoluteJoint" to link wheel to body with following code
var tJointDef:b2RevoluteJointDef = new b2RevoluteJointDef()
tJointDef.Initialize(mMainBody, mWheelBodyB, mWheelBodyB.GetWorldCenter())
tJointDef.enableMotor = true
tJointDef.maxMotorTorque = 0
tJointDef.motorSpeed = 0
mWheelJointB = mBox2D.CreateJoint(tJointDef) as b2RevoluteJoint
I try to "SetLinearVelocity" to "b2RevoluteJoint", but nothing was changed
Any friends could told me why and how to do? many thanks to you!