Codementor Events

How I improved Unity3d Timelines, with events that call arbitrary code

Published Mar 22, 2018Last updated Mar 28, 2018
How I improved Unity3d Timelines, with events that call arbitrary code

About me

I'm a long time contractor consultant, game developer, and specialist in multiple technologies including Unity3d, Virtual Reality and Mobile.

Why I wanted to learn Unity3d Timelienes

After engineering various solutions for choreographing and (especially) orchestrating game object state(such as enemies, weapons, interactables, UI, etc), I saw the Unity keynote introducing timeline, and literally jumped for joy!

Having coded flash for many years, the utility of the new technology was immediately apparent.

How I approached learning Unity3d Timelienes

I wanted to employ timeline for my project earlier on; but was already deep into development, and didn't have time to invest to spike it out and learn it thoroughly. Instead I employed it bit by bit in my project, at first for some score items (game feedback cues), and then for some enemies. However, I was so convinced by it's potential to greatly reduce development time, reduce complexity and increase reuse and legibility that I quickly embarked upon refactoring my entire project to use it!

The Unity video resources for timeline were fantastic and got me about 80% of the way to a solution. Fortunately, having had a long experience in Unity by this point, I was able to go beyond the tutorial setups to devise professional grade utilities and patterns to not only use timeline; but make it a major and seamless part of my workflow.

Challenges I faced

The major challenge was lack of events, and lack of documentation. I trawled forums, and bothered people online, as well as reading the little available code.

I wrote an extremely robust event system, which I'm soon to share on the asset store and github, which allows me to simply invoke abitrary code from my timelines. The code is flexible and powerful, and has completely transformed the way I write a large degree of my Unity code.

Key takeaways

Timeline, when well understood and appropriately used, can add so much fleixbility and power to a Unity developer's toolbox.

By leveraging timeline, a Unity dev can cut out so much code, increase flexibility and also make the scene more accesible to designers and none-coders.

I loved the challenge of writing the event system and supporting utils and I'm overjoyed with the result. The patterns I've designed allow for a gorgeous integration of code and wysiwyg concepts that will open countless doors to joyous productivity.

I'm excited to share with other's how they can use these patterns and concepts as well as the learn from the forces guiding their realization to level up their understanding of professional Unity development.

Tips and advice

Do not be scared of timeline; or on the other hand, write it off as a silly, designer only technology. Timeline, most surely is an important component in the future of Unity dev and when correctly used is a powerful tool in your arsenal, and a guiding star for helping you architect modern Unity apps and games.

Final thoughts and next steps

I'm going to shortly package up my knowledge in a github repo and asset store asset, so other's can benefit from my experincs. Next up is learning how to better merge timeline with mecanim, to solve advanced mecanim/timeline integration issues, and improving my cinemachine skills, which is clearly a first class Unity technology and will be an essential skill for all Unity devs by the time 2018 is through.

Discover and read more posts from George Cook
get started
post commentsBe the first to share your opinion
Show more replies