public void Extend() { extender = Instantiate(extendPrefab.gameObject).GetComponent <TongueExtending>(); if (transform.localScale.x < 0) { extender.direction = -1; } extender.mouth = mouth; extender.tongue = this; AudioClip clip = extendingSounds[Random.Range(0, extendingSounds.Length)]; AudioSource.PlayClipAtPoint(clip, Camera.main.transform.position); }
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); } }