mirror of
https://github.com/nothke/quality-control.git
synced 2025-08-29 23:13:43 +00:00
Working magnet and crane AI
This commit is contained in:
@@ -13,14 +13,16 @@ public class Magnet : MonoBehaviour
|
||||
{
|
||||
var otherRb = other.attachedRigidbody;
|
||||
|
||||
if(otherRb)
|
||||
if (otherRb)
|
||||
{
|
||||
Vector3 dir = otherRb.position - rb.position;
|
||||
Vector3 dir = otherRb.position - transform.position;
|
||||
float dirSq = Vector3.SqrMagnitude(dir);
|
||||
float force = strength * (1.0f / dirSq);
|
||||
|
||||
otherRb.AddForce(-dir * force);
|
||||
rb.AddForce(dir * force);
|
||||
|
||||
if (rb)
|
||||
rb.AddForce(dir * force);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user