Gravity script problem

Hello! I’m trying to make a custom gravity script and I found one from cheatsguy777 on the forums that does apply gravity. I am getting my models to walk around a planet and the gravity works fine at the top pole. but at the bottom or at the side the model just falls off. I want it to stay normal to the planet all the time and have the gravity applied in the down direction but it doesn’t become normal ever. I do have rigidbodies on everything and colliders and gravity is turned off on all rigid bodies. how could i change this script to make it work?

var planet : GameObject; 
var gravity = 2; 
function FixedUpdate(){ 
rigidbody.velocity.x = ((-transform.position.x + planet.transform.position.x)*gravity); 
rigidbody.velocity.y = ((-transform.position.y + planet.transform.position.y)*gravity); 
rigidbody.velocity.z = ((-transform.position.z + planet.transform.position.z)*gravity); 
transform.LookAt(planet.transform.position); 
}

I’m putting the script on the player walking around the planet. I’ve tried putting it on just the planet but that didn’t seem to work either. Thanks for the help!

I suggest looking through previous questions asking about relative gravity or Mario Galaxy type mechanics. I answered a similar question a while ago, it’d probably apply to you, too.