Sign in to follow this  
seejay92

P2 Contact Material Question

Recommended Posts

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!  :P

 

Thanks as ever guys! 

 

SeeJay

Share this post


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.

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...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.