Question by
gorathon_unity · Apr 09, 2018 at 12:13 PM ·
coroutinesfreezing
Coroutine Freezing Unity
Hi, I am new to unity development. I have the following coroutine that is freezing unity. Please HELP!
IEnumerator Attack()
{
currentState = State.ATTACKING;
pathfinder.enabled = false;
Vector3 origin = transform.position;
Vector3 targetPosition = target.transform.position;
float percent = 0;
float attackSpeed = 3;
while (percent <= 1)
{
percent += Time.deltaTime * attackSpeed;
float interpolation = (-Mathf.Pow(percent, 2) + percent) * 4;
transform.position = Vector3.Lerp(origin, targetPosition, interpolation);
yield return null;
}
currentState = State.CHASING;
pathfinder.enabled = true;
}
Comment
How do you know it's the coroutine that freezes Unity ? The code seems fine.
Your answer
Follow this Question
Related Questions
Why Is This Coroutine Freezing my Unity5 editor? 2 Answers
My Unity Keeps freezing; Windows 7 0 Answers
How do I make a working flashlight with batteries? 0 Answers
How to solve unity editor freezing at Application.EnterPlayMode in play mode after building? 0 Answers
Instance variables and this == null in event handler 1 Answer