private void OnCollisionEnter2D(Collision2D collision) { if (currentGrappleState == GrapplingState.Reeling) { //Debug.Log("collision check"); rb_Component.velocity = Vector2.zero; currentGrappleState = GrapplingState.Holding; } }
private void OnCollisionStay2D(Collision2D collision) { //Debug.Log("currently colliding"); if (currentGrappleState == GrapplingState.Reeling && rb_Component.velocity.magnitude <= .1f && holding == false && Time.time >= reelStartTime) { //Debug.Log("collision check"); rb_Component.velocity = Vector2.zero; currentGrappleState = GrapplingState.Holding; } }
void CheckCooldown() { // check end of cooldown if (currentGrappleState == GrapplingState.Cooldown) { if (Time.time >= grappleRechargeTime) { currentGrappleState = GrapplingState.Ready; } } }
public void HookBreak() { //break hook manually currentGrappleState = GrapplingState.Cooldown; //rb_Component.isKinematic = false; rb_Component.gravityScale = 1; grappleRechargeTime = Time.time + grappleCooldown; Destroy(currentRope); Destroy(currentHook); Destroy(currentBase); anim.SetBool("Grapple", false); }
public void StopGrapple() { showRope = false; grapplingState = GrapplingState.Normal; lr.positionCount = 0; Destroy(joint); handsAnimator.ResetTrigger("Grappling"); handsAnimator.SetTrigger("StopGrappling"); crosshair.RevertCrossHairSize(); crosshair.RevertCrosshairColor(); if (lastGrapple != null) { lastGrapple.GetComponent <MeshRenderer>().material.SetColor("_EmissionColor", original * 0.0150f); } }
public void StartGrapple() { anim.SetBool("Grapple", true); //begin hold, start shooting holding = true; currentGrappleState = GrapplingState.Shooting; // delay shoot if there is a delay, otherwise, shoot if (grappleShootDelay > 0) { Invoke("ShootGrapple", grappleShootDelay); } else { ShootGrapple(); } }
/* void StartGrapple() * { * if (grapplingState == GrapplingState.Normal) * { * GameObject close; * * if (Physics.Raycast(cameraTransform.position, cameraTransform.forward, out grappleHit, maxDistance, whatIsGrappleable)) * { * showRope = true; * lr.positionCount = 2; * autoAim = false; * aimPoint.transform.position = grappleHit.point; * aimPoint.SetActive(true); * StartGrappleHelper(grappleHit.collider.gameObject); * grapplePoint = grappleHit.point; * } * else if (playerControl.GetGrapplingAutoAimStatus() && (close = FindGrapplePoint()) != null) * { * // should i make it actually shoot to the player * showRope = true; * lr.positionCount = 2; * autoAim = true; * aimPoint.transform.position = close.transform.position; * aimPoint.SetActive(true); * StartGrappleHelper(close.gameObject); * grapplePoint = lastGrapple.transform.position; * } * } * else * { * aimPoint.SetActive(false); * } * } */ void StartGrappleHelper(GameObject g) { grapplingState = GrapplingState.Grappling; // Wait for the counter to hit zero before the grapple takes place. ropeShootCounter = ropeShootLength; // Only animate the hands if you shoot the grappling gun. handsAnimator.ResetTrigger("StopGrappling"); handsAnimator.SetTrigger("Grappling"); soundManager.PlayGrapplingSound(); lastGrapple = g; g.GetComponent <MeshRenderer>().material.SetColor("_EmissionColor", neonGreen * 0.0150f); crosshair.ChangeCrossHairColor(); }
void HoldCheck() { // end hook hold if (!holding && currentGrappleState == GrapplingState.Holding) { currentGrappleState = GrapplingState.Cooldown; //rb_Component.isKinematic = false; rb_Component.gravityScale = 1; grappleRechargeTime = Time.time + grappleCooldown; Destroy(currentRope); Destroy(currentHook); Destroy(currentBase); anim.SetBool("Grapple", false); } }
public void Reel() { // if reeling, if (currentGrappleState == GrapplingState.Reeling) { // get direction to the hook, create velocity in that direction Vector3 newVelocity; newVelocity = (currentHook.GetComponent <Hook>().lockPoint.transform.position - this.transform.position); newVelocity = Vector3.Normalize(newVelocity) * grappleReelSpeed; rb_Component.velocity = newVelocity; // if going to overshoot the lockpoint, lock onto the lockpoint if ((Vector2.Distance(this.transform.position, currentHook.GetComponent <Hook>().lockPoint.transform.position)) <= (grappleReelSpeed * Time.fixedDeltaTime)) { // Debug.Log("lockpoint check"); rb_Component.velocity = Vector2.zero; rb_Component.position = currentHook.GetComponent <Hook>().lockPoint.transform.position; currentGrappleState = GrapplingState.Holding; } } }
public void BeginReel() { // set reel state currentGrappleState = GrapplingState.Reeling; reelStartTime = Time.time + reelStartLeniency; }