예제 #1
0
    public void AttachUser(IAnchorUser _user)
    {
        m_anchor.connectedBody = _user.GetRigidbody2D();

        Vector2 dir = (Vector2)transform.position - m_anchor.connectedBody.position;

        m_anchor.connectedBody.AddForce(dir * 50f);
        m_anchor.distance     -= 0.5f;
        m_lineRenderer.enabled = true;
    }
예제 #2
0
    public void AttachToNearestAnchor(IAnchorUser _anchorUser)
    {
        AnchorComponent nearestAnchor = FindNearestAnchorComponent(_anchorUser.GetRigidbody2D().transform.position);

        if (nearestAnchor != null)
        {
            nearestAnchor.AttachUser(_anchorUser);
        }
        else
        {
            Debug.LogWarning("No anchors found to attach the body");
        }
    }
예제 #3
0
 public bool IsAttachedToUser(IAnchorUser _user)
 {
     return(m_anchor.connectedBody == _user.GetRigidbody2D());
 }
예제 #4
0
 public void AttachUser(IAnchorUser _user)
 {
     m_anchor.connectedBody = _user.GetRigidbody2D();
     m_lineRenderer.enabled = true;
 }