false gravity on a cube planet

How do you change your characters gravity and rotation so that whatever face of the cube your on, your feet point to it and the gravity pulls you toward the face. I have somewhat of an idea but I’m having trouble with the code.
heres my idea:

2715-untitled-1.jpg

You could add several triggers which act as forcefield. That way you should disable gravity itsself, but in the OnTriggerStay of the triggers, you could add force in certain directions.

edit

You can also use the OnTriggerEnter and OnTriggerExit to manage the rotation of you character.

You only need one raycast. Cast from your character’s position to the center of the cube. hit.normal will be the surface normal of the side of the cube your character is closest to (and, therefore, which side is pulling him). Have your character’s up vector become hit.normal, and then pull your character in the direction of -hit.normal. Doing it this way will work for more complex convex objects (like a capsule or cylinder) and ones that rotate too.

here’s a probably bad idea but it might be good
use transform.LookAt to point the character at the cube and check to see if the x, y and z rotations are divisible by 90, if they aren’t then they go back to what they were last frame but if they are then they stay like that.

Have you seen this?

http://forum.unity3d.com/threads/33987-Character-align-to-surface-normal

http://forum.unity3d.com/threads/39618-My-first-sucessful-script!-(Planet-Gravity-)

http://www.gamasutra.com/view/feature/3593/games_demystified_super_mario_.php

why not set the objecy that you want to pull as a child object of the planet, and then just use this instead of the raycast?
AddRelativeForce(Vector3.down * Gravity)