Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // going to use this to control horizontal velocity of player
- var playerController = new Body(BodyType.STATIC);
- playerController.space = space;
- // LineJoint is used to match the playerController horizontal kinematicVel to the players horizontal velocity.
- // we set stiff = false and maxError = 0 to disable the positional part of the constraint
- // and so the anchors really don't matter (hence just set to (0,0) here)
- var playerJoint = new LineJoint(playerController, player, Vec2.weak(), Vec2.weak(), Vec2.weak(0,1), Math.NEGATIVE_INFINITY, Math.POSITIVE_INFINITY);
- playerJoint.stiff = false;
- playerJoint.maxError = 0;
- playerJoint.space = space;
- ...
- before calling space.step()
- playerController.kinematicVel.x = whateverXVelocityYouWouldLikePlayerToHave;
Advertisement
Add Comment
Please, Sign In to add comment