Page 1 of 1

simulating steel ball collision

Posted: Tue Feb 16, 2010 2:14 pm
by drcCoder
Hey,
I'm trying to simulate two steel balls, same size and mass, hanging from strings colliding with one another. One ball is at rest and the other hits it. What I'd like to happen is that when the moving ball hits the at rest ball it transfers its speed to the other ball and stops moving. At the moment the ball that collides continues to move but a bit slower. Any suggestions would be appreciated.

Re: simulating steel ball collision

Posted: Tue Feb 16, 2010 2:30 pm
by slembcke
Do the collision shapes have 1.0 for their elasticity? You will also need a lot of iterations to simulate this well.

Re: simulating steel ball collision

Posted: Tue Feb 16, 2010 3:51 pm
by drcCoder
This is where I set up the values for the ball sprites

Code: Select all

		mySprite.position = ccp(x,y);
		myBody = cpBodyNew(100.0f, cpMomentForCircle(100.0f, 0.0f, 25.0f, CGPointZero));
		myBody->p = ccp(x, y);

		cpSpaceAddBody(game->space, myBody);

		myShape = cpCircleShapeNew(myBody,25,CGPointZero); 
		myShape->e = 1; 
		myShape->u = 0;
		myShape->collision_type =1;
And these are the value set for the space they're in

Code: Select all

		space->gravity = ccp(0, -15000);
		space->elasticIterations = 0;
		space->iterations = 20;
		space->damping = 0.85;

Re: simulating steel ball collision

Posted: Mon Feb 22, 2010 1:25 pm
by drcCoder
So, would anyone have any suggestions on how to make this work better.