Advertisement
Guest User

MagneticField

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