public IEnumerator LungeAtPlayer() { Vector2 playerDiff = player.transform.position - transform.position; lungeVelocity = playerDiff.normalized * LungeSpeed; controller.xMove = lungeVelocity.x; controller.yMove = lungeVelocity.y; controller.UpdateAnimationOnly(); controller.enabled = false; float count = 0; while (count < LungeTime) { count += Time.deltaTime; GetComponent <Rigidbody2D>().velocity = lungeVelocity * velLungeCurve.Evaluate(count / LungeTime); yield return(null); } damageableComponent.enabled = true; controller.enabled = true; currentState = State.AGGRO_IN_DISTANCE; animator.SetTrigger("LungeDone"); RandomWaitForLunge(); }
private IEnumerator MoveToPosition(TopDownController t, Vector3 pos, float time) { Vector3 diff = pos - t.transform.position; Vector3 startPos = t.transform.position; float count = 0; while (count <= time) { t.xMove = diff.x; t.yMove = diff.y; t.UpdateAnimationOnly(); t.transform.position = Vector3.Lerp(startPos, pos, count / time); count += Time.deltaTime; yield return(null); } t.gameObject.StopTopDownController(); t.transform.position = pos; }