CrossScreenFx
2015

A quick in-game code example. We were building a puzzle battle game, which includes both an orthographic tile UI, and a 3D battle scene. One of the creators wanted to make it so that when an enemy is damaged, particles flow from its body to the tile UI and replenish the tiles there. It fell to me to create both the particle effects and the system for making them move.

Challenges: These effects have to be overlayed onto the screen and make sense coming from a perspective camera, and landing onto an orthographic camera. There is little capacity for keyframe animation, because the source and destination are both indeterminate until runtime. After landing, it's not enough to immediately destroy the system either - there should be a believable "splash."

Solutions: To deal with this, I made the animation parametric: rather than lerping through a float that is managed in code (which the Unity documentation recommends, and is pretty common practice), I provide public animation curves to control the easing and the horizontal animation of the system via lerping. This is why it curves smoothly in the video before landing.

I also included a "depth fudge" parameter, to compensate for the transition from perspective to orthographic camera. This makes the particle seem to come from further away when it is released from the enemy.