2D gravity in unity (C#)

Im working on a project which uses 2D gravity. The setting is in space where you shoot projectiles, and if they are close enough to a planet, the gravity of the planet attracts the projectile. The projectile uses colliders and force applied to the rigidbody2d when fired.

This image I found explains it well:

Sorry this is my first time posting a question, so please let me know if more information is needed.