I’m a sucker for pretty effects, and I think it’s important to have a well-defined aesthetic. I also think it’s a good idea to try something out fast and dirty first to see if it works, then polish. So I recently threw together a quick effect for the main thrusters on the interceptor. I was aiming at impressive and informational; something which implies power, looks good and also helps out players.
Not bad for a first pass. So, what are the elements? Each engine has a GameObject attached behind it, and they contain a lens flare component and a trail renderer component… sort of (I’ll get to that in a minute). Additionally there’s a single point light behind the ship.
This looks nice and provides info. The flare allows players to see when others are thrusting, and the trail gives the controlling player and other players a feel for movement. Importantly though, these effects only fire while the player is thrusting. So the player also has a choice – to maneuver and become more visible, or coast and try to stay hidden.
This one’s the simplest. When the ship begins thrusting it sends an event. There’s a script which references the light, and enables it. When the ship sends an event to say it’s stopped thrusting, the light is disabled.
The flares also listen to the ship’s thrust events, and are enabled or disabled accordingly. The advantage of using a lens flare is that whenever the gameObject is occluded the flare disappears. Otherwise it’d look like the flare was a physical stream of plasma, which wouldn’t make much sense. The disadvantage is that a flare is the same size regardless of distance, which would soon fill the screen with other players’ flares. So I scale the flare’s brightness value according to its distance from the camera. By scaling the brightness, the flare appears to scale like any other physical object in the world.
This one’s a bit more tricky. If I just used the TrailRenderer component off-the-hook, it would be attached to the engine permanently. That doesn’t work well with my desire for the trail to only fire while thrusting, but remain hanging in space. The options would be having the player emit a trail all the time, or turn off the entire trail as soon as thrusting ends. Which would look terrible, obviously.
So in fact I have a prefab with a TrailRenderer component. This prefab is instantiated and parented to the engine object when thrusting starts, and then un-parented when thrusting ends. Thus the trail continues to exist but is no longer emitting new segments. TrailRenderers already have a “lifetime” property (rather than having a fixed length) so after an appropriate time the trail fades out smoothly along its length. When the trail is gone, I destroy the gameobject. Job done.
It’s not perfect. The flares are a little too big, and a little too diffuse, from a distance. I’d rather have something which literally scales, rather than decreasing in brightness. The engines on the interceptor model could do with more than just a featureless black hole; it’d be nice to have them burn brightly while thrusting, and smoulder dimly while not.