Hi, I'm currently working on a platformer/puzzle game. What I'm trying to do is add moving platforms that go up & down or left & right. I'm using a prismatic joint for this, and I've managed to make it work. Except, after a while the game starts to lag horribly.
I'm assuming this is because I keep adding a new joint every time I change motor speed. I tried removing the joints after adding a new one but that didn't work out too well. My code:
Is there a way to change motor speed without having to add a new joint every time? Or, is there a better way altogether to make moving platforms?
Thanks in advance!
I'm assuming this is because I keep adding a new joint every time I change motor speed. I tried removing the joints after adding a new one but that didn't work out too well. My code:
Code:
addEventListener(Event.ENTER_FRAME, Hover);
function Hover(event:Event) {
if (Math.round(floorBody.GetPosition().y) == 10) {
prismJoint.motorSpeed = 4.0
var joint_added:b2PrismaticJoint = Hello._world.CreateJoint(prismJoint) as b2PrismaticJoint;
}
if (Math.round(floorBody.GetPosition().y) == 15) {
prismJoint.motorSpeed = -4.0
var joint_addedd:b2PrismaticJoint = Hello._world.CreateJoint(prismJoint) as b2PrismaticJoint;
}
}
function Hover(event:Event) {
if (Math.round(floorBody.GetPosition().y) == 10) {
prismJoint.motorSpeed = 4.0
var joint_added:b2PrismaticJoint = Hello._world.CreateJoint(prismJoint) as b2PrismaticJoint;
}
if (Math.round(floorBody.GetPosition().y) == 15) {
prismJoint.motorSpeed = -4.0
var joint_addedd:b2PrismaticJoint = Hello._world.CreateJoint(prismJoint) as b2PrismaticJoint;
}
}
Is there a way to change motor speed without having to add a new joint every time? Or, is there a better way altogether to make moving platforms?
Thanks in advance!