private void StartGrab() { isGrabbing = false; if (isHolding) { return; } foreach (Vector2 direction in Enum.GetValues(typeof(CardinalDirections)).Cast <CardinalDirections>().Select(c => c.AsVector2())) { Vector2 grabPosition = transform.position2D() + direction; Collider2D collide = Physics2D.OverlapPoint(grabPosition); if (collide == null) { continue; } IGrabbable grabbable = collide.GetComponent(typeof(IGrabbable)) as IGrabbable; if (grabbable != null && grabbable.CanGrab()) { stepState.GrabPosition = grabPosition; isGrabbing = true; Rock = ((GameObject)GameObject.Instantiate(RockPrefab, grabPosition, Quaternion.identity)).transform; grabbable.OnGrab(); break; } } }