Friday, September 27, 2013

Update 20: Alpha 1.56 - Timing

One of the biggest bugs in my code has been the timing of the camera movement, shooting and throwing. I've put off solving these problems for a variety of reasons, but with some early AI experiments, I found that it suddenly became essential to solve this immediately.

Fundamentally, the issues come from my usage of Coroutines, a Unity function that runs until it is finished. It's almost the same as creating a new thread. I use coroutines for my camera movement, shooting, throwing, and soon, for AI.

My game is simple, but still complex enough that I decided to create a separate  isolated test level to solve this problem. This little doodle shows my plan. I need two 'paddles', a ball to bounce back and forth, and the camera to switch between the two paddles between bounces. This functionality is all very similar to the way my camera follows a character taking their turn, and has them shoot/throw an object at an enemy.



With this design, my test looks like this:


I was able to easily try a few different tests, running through the 5 steps designed above, firing two projectiles instead of one, and really ensuring that the timing was working. I found that I could never get coroutines to wait. My bug was relatively simple (of course), and I've spent the last few hours actually refactoring the main branch of the code. Once this is working, I'll post about the AI.

No comments:

Post a Comment