Quantcast
Channel: Latest Questions on Unity Answers
Viewing all articles
Browse latest Browse all 171066

How to update new frame while another is computing?

$
0
0
Hi! I'm doing a checkers program and I want to show to screen the human while the program is computing the move of the AI. Here goes the transition between the Human and Computer move: void FinishHumanMove(GivenMove givenMove) { ApplyMove(pieceOnBoard,givenMove); UpdateBoard(); //Visual Update ComputerTurn(); } void ComputerTurn() { currentPlayer = WhoIsPlaying.Computer; GivenMove chosenComputerMove = MinimaxDecision(pieceOnBoard,7); ApplyMove(pieceOnBoard,chosenComputerMove); UpdateBoard(); //Visual Update UpdateTileComputerMove(chosenComputerMove); //Visual Update HumanTurn(); } However, because the computation time is quite long is the ComputerTurn() function, the UpdateBoard in the FinishHumanMove() does not finish, hence there is a feeling of lag. I checked the yield function and coroutine, but i don't know how to use them to solve my problem. Any suggestion to how to finish the rendering of the UpdateBoard() while computing the ComputerTurn?? Thanks.

Viewing all articles
Browse latest Browse all 171066

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>