sorry to keep bothering you, but I'm getting another error when entering battle.
One small thing to note is that if I comment out the line with viewport.z the animation works in battle, but when the battle ends i get another error about 'color' being undefined.