System.Collections.IEnumerator PerformDash()
{
isDashing = true;
canDash = false;
Vector3 dashDirection = new Vector3(inputVec.x, inputVec.y, 0).normalized;
float angleOffset = 180f;
float angle = Mathf.Atan2(dashDirection.y, dashDirection.x) * Mathf.Rad2Deg + angleOffset;
Quaternion rotation = Quaternion.AngleAxis(angle, Vector3.forward);
Vector3 dashEffectPosition = transform.position + dashDirection * -dashEffectOffset.magnitude;
dashEffectInstance = Instantiate(dashEffectPrefab, dashEffectPosition, rotation);
Animator dashEffectAnimator = dashEffectInstance.GetComponent<Animator>();
float dashEffectDuration = 0.0f;
if (dashEffectAnimator)
{
dashEffectAnimator.SetTrigger("DoDash");
dashEffectDuration = dashEffectAnimator.GetCurrentAnimatorStateInfo(0).length;
}
StartCoroutine(DestroyDashEffectAfterAnimation(dashEffectInstance, dashEffectDuration));
float dashEndTime = Time.time + dashDuration;
while (Time.time < dashEndTime)
{
rb.MovePosition(rb.position + (Vector2)dashDirection * dashSpeed * Time.fixedDeltaTime);
yield return null;
}
yield return new WaitForSeconds(dashCooldown);
isDashing = false;
}
주석은 귀찮아서 안달았음
고마웟 사릉함