Script that would allow you to focus gravity?

I want to make a game kind of like mario galaxy where you walk around a planet,

if you can see, mario walks around the planet and the planet kind of spins around. What I was wondering is how would you do this and is there a way that you can focus gravity on a certain point. I have seen it done in other unity games where the player has a gravity gun type of thing.

EDIT

WOW I just found this game this is very similar to what I want to make…

I’d recommend checking out this article, which describes the method that (I believe) is commonly used for this.

To summarize the method:

  • Cast a ray straight down from the character to find the intersection point and normal for the surface beneath him (if any).

  • Align the character’s local up vector with the surface normal. (In practice you’ll probably want to use interpolation for a smoother effect.)

  • Move the character so that his feet are more or less positioned at the contact point.

That’s a very simple overview of course (once you introduce things like jumping, collision with obstacles, and so on, it gets a little more complex).

There’s a script on the wiki that does this.

As with most things on the wiki, this probably originated with a forum post. I’d search the forums for it.

Awesome thanks