Jump to content
This forum will be closing down. Please move to the respective dedicated project forums.

p2js prismatic springs


gauravD
 Share

Recommended Posts

Hi.

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 comment
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 comment
Share on other sites

Okay. Fixed.

http://jsfiddle.net/gauravdixitv/6acmp7h5/

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 comment
Share on other sites

 Share

  • Recently Browsing   0 members

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