Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- foreach (Transform nearObject in nearObjects)
- {
- Vector3 delta = transform.position-nearObject;
- float forceAmount = (1 / delta.sqrMagnitude) * mass;
- float forceDirection = delta.normalized;
- nearObject.rigidbody.AddForce( forceDirection * forceAmount );
- }
Advertisement
Add Comment
Please, Sign In to add comment