void Update() { if (!dashing) { Vector3 inputDirection = GetInputTranslationDirection(); if (inputEnabled) { rb.velocity += camera.TransformDirection(inputDirection) * accelPerSec; } rb.velocity = rb.velocity.normalized * Mathf.Min(maxSpeed, rb.velocity.magnitude); // Debug.Log(Vector3.Distance(transform.position, curTargetPlanet.position)); // begin windup if (SPEAR.spearIsReady && Input.GetMouseButtonDown(0)) { spearReady = true; spearTime = 0f; if (bunnyAnimator != null) { bunnyAnimator.SetBool("throwWindUp", true); } } // continue windup if (spearReady && Input.GetMouseButton(0)) { spearTime += Time.deltaTime; float lerpVal = Mathf.InverseLerp(0f, .617f, spearTime); if (aim != null) { aim.strength = lerpVal; } orbitCam.m_Lens.FieldOfView = Mathf.Lerp(FOVRange.x, FOVRange.x - 15f, lerpVal); } // release windup if (spearReady && !Input.GetMouseButton(0)) { spearReady = false; if (aim != null) { aim.strength = 0f; } if (SPEAR.Launch()) { SpearThrow.PlayOneShot(SpearThrow.clip); if (bunnyAnimator != null) { bunnyAnimator.SetBool("throwWindUp", false); } StartCoroutine(animateFOV()); } } if (Input.GetKeyDown(KeyCode.Space)) { StartCoroutine(Dash(inputDirection * dodgeForce)); } } // Debug.Log(Vector3.Distance(transform.position, curTargetPlanet.position)); if (Vector3.Distance(transform.position, curTargetPlanet.position) > orbitRadius + orbitSoftWidth) { rb.velocity += orbitCorrectForce * (curTargetPlanet.position - transform.position) * Time.deltaTime; } else if (Vector3.Distance(transform.position, curTargetPlanet.position) < orbitRadius - orbitSoftWidth) { rb.velocity += -orbitCorrectForce * (curTargetPlanet.position - transform.position) * Time.deltaTime; } Vector3 XYvelocity = Vector3.ProjectOnPlane(looker.transform.InverseTransformDirection(rb.velocity), looker.transform.forward); XYvelocity = XYvelocity.normalized * (Mathf.Min(XYvelocity.magnitude, 1f)); ffx = Mathf.SmoothDamp(ffx, XYvelocity.x, ref ffxVelocity, ffxSmoothTime, ffxMaxSpeed); ffy = Mathf.SmoothDamp(ffy, XYvelocity.y, ref ffyVelocity, ffySmoothTime, ffyMaxSpeed); bunnyAnimator.SetFloat("flyX", ffx); bunnyAnimator.SetFloat("flyY", ffy); }