333GameStudio

MagneticField

May 29th, 2016
3,463
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var Magnet : GameObject;
  2. var forceFactor : float = 10;
  3.  
  4. function Update () {
  5.  
  6.  
  7.  GetComponent.<Rigidbody>().AddForce((Magnet.transform.position - transform.position) * forceFactor * Time.smoothDeltaTime);
  8.  
  9.  
  10. }
Advertisement
Add Comment
Please, Sign In to add comment