Created
September 24, 2013 10:28
-
-
Save poga/6682939 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
while (!targetUnit.IsDead()) { | |
actor.animation.Play("run"); | |
while (Vector3.Distance(actor.transform.position, target.transform.position) > actorUnit.attackRange) { | |
actorUnit.MoveTo(target.transform.position); | |
yield return null; | |
} | |
while (Vector3.Angle(actor.transform.forward, target.transform.position - actor.transform.position) > 10) { | |
actorUnit.RotateToward(target.transform.position); | |
yield return null; | |
} | |
actor.animation.Play("attack"); | |
yield return new WaitForSeconds(actorUnit.attackStartDelay * playbackRate); | |
// Attack actually happen | |
actorUnit.Attack(target); | |
// Wait the rest of animation complete | |
yield return new WaitForSeconds(attackAnim.length * playbackRate - actorUnit.attackStartDelay * playbackRate); | |
actor.animation.Play("idle"); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment