- Home /
 
I have a planetary gravity script; how do I make the object speed up?
Basically, I have a planetary gravity script and it works okay. It pulls any objects with a rigidbody towards it, but it moves towards it at the same speed. What do I add to the script to make the object speed up as it falls?
 var range : float = 30.0;
  
 function FixedUpdate () {
     var cols : Collider[] = Physics.OverlapSphere(transform.position, range);
     var rbs : Array = new Array();
     for (c=0;c<cols.length;c++) {
         if (cols[c].attachedRigidbody && cols[c].attachedRigidbody != rigidbody) {
             var breaking :boolean = false;
             for (r=0;r<rbs.length;r++) {
                 if (cols[c].attachedRigidbody == rbs[r]) {
                     breaking=true;
                     break;
                 }
             }
             if (breaking) continue;
             rbs.Add(cols[c].attachedRigidbody);
             var offset : Vector3 = (transform.position - cols[c].transform.position);
             var mag: float = offset.magnitude;
             cols[c].attachedRigidbody.AddForce(offset/mag/mag * rigidbody.mass);
         }
     }
 }
 
              Answer by meat5000 · Oct 07, 2013 at 06:33 PM
Perhaps some expression of time in AddForce? Or maybe just some moveFaster += 1; for some linear action in your life. Perhaps play with ForceMode
Your answer
 
             Follow this Question
Related Questions
Physics gravity appears very weak 2 Answers
Add velocity relative to ground? 1 Answer
How to make a object jump constantly at y and move to the next position to z (perfectly) 0 Answers
How can I turn on/off Rigidbody.useGravity? 0 Answers
How to make rigidbodies on each side of a cube fall towards the cube? [multiple gravity / addForce] 0 Answers