Gravity issue and issue with vector3 calculations

the script i am running is as follows:

var resForce =;
var Planet : Transform;
var Player : Transform;
var dir = Planet.position - transform.position;
var dist2 = dir.sqrMagnitude;
var gForce = g * Planet.rigidbody.mass / dist2;
var g = (0.000000000006674);
Planet = GameObject.Find("SpherePlanet").transform;
Player = GameObject.Find("Sphere").transform;
function Start () {
function Update () {
var RelativePos = Planet.position - Player.position;
resForce += gForce * dir.normalized;

the issue i have is that the vecotr3 never brings the rigidbody it acts upon toward the object, and it shoots off infinitely at high velocity. i am looking for both math and code errors at thie point, terribly new to programming in unityscript.

I think the problem is that your AddForce is inside the Update function. What’s happening is that Unity is applying a force to the object at every frame and so you get the high velocity. You should use a flag or a trigger so the AddForce function will be called only once.