Jump to content

P2 Revolute Constraint not playing well with gravity


Recommended Posts

Hey guys! I'm just starting out with Phaser game programming. I'm trying to build a proof of concept rope system.



I for some reason, when I apply gravity, the revolute joint fails. Not sure what to do. Any ideas? Also, I'm running off the dev branch.



You can find my demo here:




preload: function() { 		game.load.image('rope_piece', 'assets/rope_piece.png');     },    create: function() { 		cursors = game.input.keyboard.createCursorKeys();				game.physics.startSystem(Phaser.Physics.P2JS);				rope_1 = game.add.sprite(100,100,'rope_piece');				rope_2 = game.add.sprite(100,110,'rope_piece');				game.physics.p2.enable([rope_1]);		game.physics.p2.enable([rope_2]);		//game.physics.p2.enable([rope_3]);				game.physics.p2.gravity.y = 100;				//rope_1.body.clearCollision(true, true);		//rope_2.body.clearCollision(true, true);				//rope_1.body.mass = 0;		rope_1.body.data.motionState = 2;		//rope_2.body.data.motionState = 1;								constraint = game.physics.p2.createRevoluteConstraint(rope_1, [0,-5], rope_2, [0,5]);		    },        update: function() {		if (cursors.up.isDown)		{			rope_2.body.thrust(50);		}				 else if (cursors.right.isDown)		{			rope_2.body.rotateRight(5);		}				//rope_1.body.setZeroVelocity();    },
Link to comment
Share on other sites


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...