Gravity around a torus (donut shape)

Hi, I wanted to know how to put gravity on a torus so that my character can walk on all the exterior surface around the torus. Is there a way to do this?
Thank you

Calculate closest point on the core of the torus (circle) to the character. Apply acceleration in that direction.

But will not this point constantly change according to the location of my character? For example if my character is on the top of the torus or on the surface that forms the rebounds of the hole.

An easy way might be to use one of the many spline tools available on the asset store. You can then make a spline that is at the ‘centre’ of the volume of the torus and use spline functions like GetClosestPointOnSpline( characterPosition) to determine what the gravity direction should be.

Vector3 gravityDirection = (characterPosition - spline.GetClosestPointOnSpline( characterPosition)).normalized;

This is essentially the same as what Plystire suggested, splines are an easy way to implement it. It also allows you to make it work for a number of different tube shapes as well.

I made a setup in which the gravity adapts to your surface, that might be a good starting point for you:

No, not if you’re finding the closest point on the circle to your character. This circle is inside your donut and represents all internal points that are furthest from the surface of the torus – it’s “center circle”. By that definition, should your character walk “through” the donut from one side to the other, their closest point on the circle remains the same, and they should be accelerated toward the same point.

Here’s a handy function I found for finding this point: https://stackoverflow.com/questions/6571202/closest-point-on-circle-in-3d-whats-missing

Johannski’s implementation would be far more adaptive to a wide variety of body shapes though.
[EDIT] I am curious to know what Johannski’s model will do if the character attempted to jump across the gap of the donut…