Make a game object move inside circle and bounce from walls without gravity

I have a circle with a RigidBody2D and CircleCollider2D components on it.

I'm trying to make it move constantly inside a bigger circle without gravity involved, make it bounce off the circle walls like it has constant velocity but without any delays, same speed all the time.

Here is an example of the same behaviour but inside a rectangle:

I would like to do the same but inside a circle and detect the collision with the circle walls

• I'm trying to change the transform position until I reach a destination point and then take another random point on the circle and get to it, But it's not a physics based solution, I want it to bounce out of the circle walls like a real physics collision, not to a random position Commented Mar 9, 2018 at 10:56

Some suggestions to get you started:

1. Change your rigidbody gravity scale to 0 and mass to 0.
3. Use the EdgeCollider component for your shape you want to bounce off.

Good luck

• Thanks for the reply, this is not the answer, I already have my mass at 0 and gravity at 0, the thing with AddForce() is not clear to me, when to add force? how match? on Start? Every update? Commented Mar 9, 2018 at 15:49
• You only have to AddForce once, if your object has no mass, gravity or drag. It should bounce around forever. Look at physics materials for your collider on your moving object too, then you can control its bounciness for e.g. Commented Mar 9, 2018 at 16:01
• It works, I've created a new Physics Material 2D named Bouncy with a friction of 0 and bounciness of 1 and added it to the ball, it now works great. Thanks Commented Mar 9, 2018 at 16:25
• I'd recommend keeping some mass on the object, otherwise force calculations get a bit weird (acceleration = force / mass which approaches infinity as mass approaches zero). Mass itself won't slow the object down (quite the opposite - inertia due to mass resists slowing down) as long as you've turned off the drag. Commented Mar 9, 2018 at 17:28