[Matterjs] Bounce ball off the world's walls

Hello,

How can I achieve ball reflection of the wall like in images below:

After kicking black ball by red player the black ball goes the path described by blue arrow then after collision with world wall changes direction and goes the path described by green arrow and stops in yellow point.

  1. Zrzut ekranu z 2021-08-20 21-45-22
  2. Zrzut ekranu z 2021-08-20 21-45-32
  3. Zrzut ekranu z 2021-08-20 21-45-47

Currently after kicking black ball by red player the ball goes the path described by blue arrow then after collision black ball stops by the wall instead of going the path described by green arrow and stops in yellow point.

I’ve tried set up parameters using this example Phaser - Examples - Circle Body

ball.setVelocity(x, y);
ball.setAngularVelocity(velocity);
ball.setBounce(bounce);
ball.setFriction(a, b, c);

But I don’t know how to calculate velocity (x, y) after collision. :confused:

Will be grateful for any hints. :slight_smile: