# How to calculate a RigidBody2D's bounce from a collider?

Ok, so after trying to figure it out by myself for the last three days I’m finally ready for some help :P.

I’m building circle pong like game and i’ve been trying to implement a mechanic where time slows down to almost a halt (0.0001) for everything ingame except the player. During this slowmotion mode i want to show the trajectory that the ball will take after time is back to normal, like this:

But when i’m using this code to calculate the trajectory:

``````LayerMask playerMask = LayerMask.GetMask("Player");

while (active){
Vector2 dir = this.transform.position - ball.transform.position;
if (hit.point != null) {
lr.SetPosition(0, ball.transform.position);
lr.SetPosition(1, hit.point);
Vector2 ballpos2d = new Vector2(ball.transform.position.x, ball.transform.position.y);
Vector2 ballTrajectory = Vector2.Reflect( hit.point - ballpos2d, hit.normal);
lr.SetPosition(2, ballTrajectory * 50);
}
yield return null;
}

}
``````

The ball is set to dynamic rigidBody2D with no mass or drag and physics material2D with 0.3 bounce and no friction.The problem is that the ball off by some degree, like this:

So is there any way to calculate how physics based object would bounce off a collider?

For a simple style like that I would encourage you to write your own physics from scratch, you would have way more control and then this kind of operation would become trivial.

Barring that, I don’t believe it is possible to force a physics Update, because physics are based on time, so if no time has passed then nothing will happen, but you want an answer each frame.

Another option is to (with some trial and error) is to use the velocity of the ball (rigidbody.velocity) to figure out where the ball is going and how it would bounce when it hits the next object along it’s path.