public override void Release() { //m_aim.Hide(); if (m_chargeTime > LongDashChargeThreshold) { NavMeshAgent activeAgent = m_skillController.ActiveAlly.ParentFollower.gameObject.GetComponent <NavMeshAgent>(); activeAgent.enabled = false; if (m_motor.WarpTo(m_aim.Target, Radius)) { m_motor.Movement = PlayerMotor.MovementStyle.Free; } m_aim.OuterRadius = m_oldRadius; m_aim.Recenter(); activeAgent.enabled = true; // Fall through to standard dash? } else { if (m_motor.Velocity == Vector3.zero) { m_launchable.Launch(m_aim.Direction * m_initialSpeed, m_deceleration, 0); } else { m_launchable.Launch(m_motor.Direction * m_initialSpeed, m_deceleration, 0); } if (m_invincibilityCountdown != null) { StopCoroutine(m_invincibilityCountdown); } m_invincibilityCountdown = StartCoroutine(InvincibilityCountdown(InvincibilityTime)); if (m_unlockCountdown != null) { StopCoroutine(m_unlockCountdown); } m_unlockCountdown = StartCoroutine(UnlockCountdown(FreezeMovmentControlTime)); } m_chargeTime = 0f; }
// Update is called once per frame public void Update() { if (Input.GetKeyDown(KeyCode.Mouse0)) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hitInfo; bool hit = Physics.Raycast(ray, out hitInfo); if (hit) { Vector3 velocity = LaunchSpeed * (hitInfo.point - transform.position).normalized; velocity.y = 0f; m_launchable.Launch(velocity, Deceleration, Bounces); } } if (Input.GetKeyDown(KeyCode.R)) { transform.position = m_startPos; m_launchable.InterruptLaunch(true); } }
public void Update() { if (m_speed > 0f) { Vector3 offset = m_endRotation * (m_speed * Time.deltaTime * Vector3.forward); NavMeshHit hit; bool hasHit = m_motion.Agent.Raycast(transform.position + offset, out hit); if (!hasHit || Vector3.Angle(-offset, hit.normal) >= GlancingAngleThreshold) { if (!m_isCharging) { float newSpeed = m_speed - (Friction * Time.deltaTime * Time.deltaTime); m_speed = Mathf.Clamp(newSpeed, 0f, MaxChargeSpeed); } m_motion.Move(offset); } else if (m_speed > CrashSpeedThreshold) { // EXPLOOOSION Vector3 reflection = Vector3.Reflect(offset.normalized, hit.normal); m_launchable.Launch(reflection * m_speed * RecoilElasticity, Friction); m_motor.enabled = true; m_isCharging = false; m_speed = 0f; } else { m_motor.enabled = true; m_isCharging = false; m_speed = 0f; } } }