Friday, October 22, 2010

Unity Crash Course

This week I attended a lecture series in Unity hosted by ITU. Two nice guys from Unity, Joe and Emil, gave a guide tour through a lot of Unity's features from animation, textures, GUI and editor scripting. They covered tons of stuff and it turned out to be a nice introduction to Unity.

Adding to the greatness of it all was the time given to questions from the audience. I got to ask what was wrong with the sprite sheet animation code since it was giving my this odd graphics problem over time. At first Joe found it just as strange as me but after a trip back to the Unity-factory he could give me the solution.

It turns out the offset float value on the y-axe kept in increase over time. This would be fine if it wasn't for the fact that the float as it increased would be round up thereby constantly increasing in inaccuracy.

Solution: Adding Mathf.Repeat to the offset's x value with the length of 1.
offset.y = Mathf.Repeat(offset.y,1);
This ensures the value every time it goes above 1 is returned to count from 0 instead.

And now it works! Yaaahhhhhh!

No comments:

Post a Comment