seejay92 Posted October 24, 2014 Share Posted October 24, 2014 Hi everyone, Just a quick question for those with experience using P2. I'm creating a simple 2D sidescrolling golf game (using Typescript) and I've set up a polygon array creating random terrain Y points and a ball with P2 physics. The collisions between both using the contact material work perfectly, including Restitution and Surface Velocity but I was wondering if there was anyway to create drag when the ball rolls over the terrain. Just now, if there is even a slight hint of angle to a hill the ball will continue to roll down it due to gravity without any drag to slow it, or even if its flat it will continue at a steady pace. I've tried changing the contact material's friction to extremely high but this doesn't seem to have much affect slowing the velocity. Here's the settings for my contact material: this.contactMaterial.friction = 1e7; this.contactMaterial.restitution = 0.4; this.contactMaterial.surfaceVelocity = 0; // contactMaterial.stiffness = 1e7; // contactMaterial.relaxation = 3; // contactMaterial.frictionStiffness = 1e7; // this.contactMaterial.frictionRelaxation = 0.1;The temporary fix would be to call an event for when the two materials are touching which slows the ball's velocity to closer to 0, but I'm sure theres something easier I'm just missing as this is my first time using P2. Also as a little extra, could someone explain what the commented out properties of the material do? I know roughly what stiffness and relaxation do with Springs but I'm not too sure what affect they have in contact materials - they are probably the properties I need properly set to achieve my drag! Thanks as ever guys! SeeJay kctang 1 Link to comment Share on other sites More sharing options...
wayfinder Posted November 4, 2014 Share Posted November 4, 2014 have you tried looking at the p2 docS? Link to comment Share on other sites More sharing options...
Recommended Posts