# \[Matterjs\] Bounce ball off the world's walls

**URL:** <https://phaser.discourse.group/t/matterjs-bounce-ball-off-the-worlds-walls/10140>\
**Category:** Phaser 3\
**Created:** [August 20, 2021, 8:34pm UTC](https://phaser.discourse.group/t/matterjs-bounce-ball-off-the-worlds-walls/10140 "2021-08-20T20:34:16Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![MajorKuprich](https://avatars.discourse-cdn.com/v4/letter/m/bcef8e/32.png) [@MajorKuprich](https://phaser.discourse.group/u/MajorKuprich)\
**Post date:** [August 20, 2021, 8:34pm UTC](https://phaser.discourse.group/t/matterjs-bounce-ball-off-the-worlds-walls/10140/1 "2021-08-20T20:34:16Z")

</div>

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](https://global.discourse-cdn.com/free1/uploads/phaser1/original/2X/5/52df70176b10408110477e7f7499a1dbcf9a00ec.png)
2. ![Zrzut ekranu z 2021-08-20 21-45-32](https://global.discourse-cdn.com/free1/uploads/phaser1/original/2X/7/73d650b3c448d8893a256de87b0340f38d95298a.png)
3. ![Zrzut ekranu z 2021-08-20 21-45-47](https://global.discourse-cdn.com/free1/uploads/phaser1/original/2X/c/ca9f3736db7ea9120dc89e7a4334c0aae5dfb8b1.png)

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](https://phaser.io/examples/v3/view/physics/matterjs/circle-body)

```javascript
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. 😕

Will be grateful for any hints. 🙂
