//In terms of this it is Releasing the grapple, deflect public override void FinishAbility() { //So when it's finished it should clean itself up //So it'll finish by starting a destroy animation? or just destroy it here temporarily //It'll return to the player and then destroy itself GetComponent <BoxCollider2D>().enabled = false; Spring.connectedBody = Spring.GetComponent <Rigidbody2D>(); Joint.connectedBody = Joint.GetComponent <Rigidbody2D>(); StartCoroutine(ReturnDestroy()); IEnumerator ReturnDestroy() { yield return(new WaitForSeconds(Time.deltaTime)); Vector2 PlayerPos = FindObjectOfType <CharacterController2D>().transform.position; Debug.Log("2011: Bonk " + Vector2.Distance(transform.position, PlayerPos)); if (Vector2.Distance(transform.position, PlayerPos) < 1f) { //So if we're within distance of the player we should start a cleanup routine. Destroy(this.gameObject); } else { transform.position = Vector2.MoveTowards(transform.position, PlayerPos + new Vector2(0, 0.5f), Speed * Time.deltaTime); StartCoroutine(ReturnDestroy()); } } }
void GrappleItBoy(Collider2D otherCollider, Vector3 point, Vector3 normal) { grappleStart.Invoke(); joint.autoConfigureDistance = true; joint.GetComponent <DistanceJoint2D>().enabled = true; grapplePoint = point; Instantiate(grappleParticles, grapplePoint, Quaternion.identity); hookEnd.position = point + (normal * penetrationAmount); hookEnd.SetParent(otherCollider.transform); foreach (Transform tran in objectsToMoveToGrapplePoint) { tran.position = point; } joint.connectedBody = otherCollider.attachedRigidbody; joint.connectedAnchor = otherCollider.transform.InverseTransformPoint(hookEnd.position); joint.enableCollision = true; //joint.distance = Vector3.Distance(point, transform.TransformPoint(joint.anchor)); joint.autoConfigureDistance = false; //StartCoroutine(GrappleRoutine()); characterControlScript.canJump = true; }