Jump to content

P2 Revolute Constraint not playing well with gravity


sndbarrier1
 Share

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:

https://dl.dropboxusercontent.com/u/21728452/Games/phaser-master_V2/rope/index.html

 

Thanks!

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

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