mirror of
https://github.com/nothke/quality-control.git
synced 2025-08-30 07:23:43 +00:00
More realistic magnets and a little bit of waiting time
This commit is contained in:
@@ -17,12 +17,13 @@ public class Magnet : MonoBehaviour
|
||||
{
|
||||
Vector3 dir = otherRb.position - transform.position;
|
||||
float dirSq = Vector3.SqrMagnitude(dir);
|
||||
float force = strength * (1.0f / dirSq);
|
||||
float forceMagnitude = strength * (1.0f / dirSq);
|
||||
Vector3 force = dir.normalized * forceMagnitude;
|
||||
|
||||
otherRb.AddForce(-dir * force);
|
||||
otherRb.AddForce(-force);
|
||||
|
||||
if (rb)
|
||||
rb.AddForce(dir * force);
|
||||
rb.AddForce(force);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user