private void AttractInDirectionOf(Vector2 direction) { direction.Normalize(); var thisPos = new Vector2(transform.position.x, transform.position.y); var hits = Physics2D.RaycastAll(thisPos, direction, BeamLength); foreach (var hit in hits.Where(h => h.rigidbody != null)) { Vector2 force = direction * BeamForce; hit.rigidbody.AddForce(force * -1); rigidbody.AddForce(force); } Vector3 forward3 = Tip.transform.position - transform.position; Vector2 forward = new Vector2(forward3.x, forward3.y).normalized; float angle = Vector2.SignedAngle(forward, direction); if (hits.Length > 0) { audioManager.UnmuteMagnet(); rigidbody.AddTorque(Torque * Mathf.Sign(angle)); } else { audioManager.MuteMagnet(); } }