Quantcast
Channel: Questions in topic: "unitywebplayer"
Viewing all articles
Browse latest Browse all 452

Animation for character movement not being stopped on Task.WhenAll()

$
0
0
Currently have a await for my character movement (2 characters run into position once they reach their destination) the issue is the run (movement) animation doesn't stop even when I break out of one of the loops. It is waiting for both to finish the while loop, any ideas?: async Task MoveCharacter(Character character, int n) { character.SetMoveAnimation(true); while (Vector3.Distance(character.transform.position, character.PositionData[n].transform.position) > .01f) { character.transform.position = Vector3.MoveTowards(character.transform.position, character.PositionData[n].transform.position, Time.deltaTime * 3f); await Task.Yield(); } //Shouldn't this be called on the character to stop it's animation when it reaches the destination? character.SetMoveAnimation(false); } List TaskList = new List(); TaskList.Add(Move(characterA, n)); TaskList.Add(Move(characterB, n)); await Task.WhenAll(TaskList.ToArray());

Viewing all articles
Browse latest Browse all 452

Trending Articles