duck

duck

Jul 16th, 2010
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. foreach (Transform nearObject in nearObjects)
  3. {
  4.     Vector3 delta = transform.position-nearObject;
  5.     float forceAmount = (1 / delta.sqrMagnitude) * mass;
  6.     float forceDirection = delta.normalized;
  7.     nearObject.rigidbody.AddForce( forceDirection * forceAmount );
  8. }
Advertisement
Add Comment
Please, Sign In to add comment