public void OnTriggerStay2D(Collider2D collision) { var gravityObjectRB = collision.GetComponent <ControllableGravityObjectRigidBody>(); if (gravityObjectRB && gravityObjectRB == _currentlyTracking) { Collider2D MagnetCollider = GetComponent <Collider2D>(); var dis = MagnetCollider.Distance(collision); var dir = dis.normal * Mathf.Abs(dis.distance); var forceVector = Vector3.zero; var changeInGravDirection = dir.normalized - GORB.GravityDirection; var newGravDirection = GORB.GravityDirection + changeInGravDirection * MagnetStrengthControllableTarget * Time.deltaTime; GORB.ChangeGravityDirectionInternal(newGravDirection.normalized); } }
public void ChangeGORBGravityDirection(GravityObjectRigidBody GORB, Vector2 dir) { GORB.ChangeGravityDirectionInternal(dir); }