the script i am running is as follows:
var resForce = Vector3.zero;
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;
rigidbody.AddForce(resForce);
Debug.Log(RelativePos);
}
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.