Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

>> REGISTER NOW TO START POSTING

Members have full access to the forums. Advertisements are removed for registered users.

# Thread: Need Urgent he-lp - Phys2D - Bodies doesn't bounce back after collision...

1. ## Need Urgent he-lp - Phys2D - Bodies doesn't bounce back after collision...

In my code there are two balls with certain velocity both from different direction collide with eachother... After Collision they are supposed to bounce back with certain velocity...But in my code they just stuck together the moment the collide eachother.

I tried to set restitution value 15 for both bodies, but the bodies vanish after collision...
Any help would be highly appreciated.

Thanks in advance>>

```protected void init(World world) {

world.setGravity(0,0); //

Body BallA= new Body("Cart", new Circle(15), 100);

Body BallB= new Body("Cart", new Circle(15), 100);

BallA.setPosition(150, 375);
BallB.setPosition(300, 375);

BallA.adjustVelocity(new Vector2f(20f, 0f));
BallB.adjustVelocity(new Vector2f(-20f, 0f));

//          ball1.getBody().setRestitution(15);
//          ball2.getBody().setRestitution(15);

world.add(ball1);
world.add(ball2);

}```

2. ## Re: Need Urgent he-lp - Phys2D - Bodies doesn't bounce back after collision...

Post the Body class.

3. ## Re: Need Urgent he-lp - Phys2D - Bodies doesn't bounce back after collision...

Thanks, Actually I tried different Restitution value between 0.3 to 0.9 and its working fine now.

However, if u r interested, following are the links:

Phys2d Javadocs:
Generated Documentation (Untitled)

Phys2d SourceCode:
Index of /phys2d/source/src/net/phys2d/raw