Jump to content

p2js prismatic springs

Recommended Posts


Prismatic and Spring joints in p2js seem pretty straightforward. I was wondering why using constant rest length, stiffness and damping for a spring would change its behavior when a body's local anchor is changed.

Fiddle: http://jsfiddle.net/gauravdixitv/83bkhr3f/  (phaser/p2js template from inkfood)

From the fiddle, all the springs use share the same parameters except the local anchor of body A. Why do the springs behave differently? :/ 

Link to post
Share on other sites

I tried removing all prismatic constraints from your demo and it still looks weird. The wheels are pulled to the left by some force. I haven't seen this in the p2.js library before, so for now I think there is a bug is in the Phaser P2 plugin?

Edit: Oh wait. I think it might just be the buggy rendering of springs?

Link to post
Share on other sites

Okay. Fixed.


Turns out Phaser uses physics.p2.pxmi (pxm inverse) to anchor a prismatic joint - https://github.com/photonstorm/phaser-ce/blob/master/src/physics/p2/PrismaticConstraint.js#L39

BUT, physics.p2.pxm to anchor a linear spring - https://github.com/photonstorm/phaser-ce/blob/master/src/physics/p2/Spring.js#L59

What is up with this ?:o

Link to post
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.

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.

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...