Ejemplo n.º 1
0
 public void Attach(GameObject newTarget, Vector3 attachPos)
 {
     // TODO attach to the target!
     extender = null;
     CreateSegments(attachPos);
     if (newTarget != null)
     {
         AudioSource.PlayClipAtPoint(attachSound, Camera.main.transform.position);
         target = newTarget.GetComponent <HingeJoint2D>();
         target.connectedBody = links[links.Length - 1].GetComponent <Rigidbody2D>();
         target.anchor        = target.transform.InverseTransformPoint(attachPos);
         target.enabled       = true;
         target.SendMessage("TongueAttached", attachPos, SendMessageOptions.DontRequireReceiver);
     }
 }
Ejemplo n.º 2
0
 public void Detach()
 {
     if (links != null)
     {
         foreach (TongueLink link in links)
         {
             Destroy(link.gameObject);
         }
         links = null;
     }
     if (target != null)
     {
         target.SendMessage("TongueDetached", SendMessageOptions.DontRequireReceiver);
         target.enabled = false;
         target         = null;
     }
 }