The year is 1891 and the triumph of alternating current has sent Edison into a violent rage. It is up to you, playing as Nikola Tesla, to defeat an army of DC-powered robots and prove that you are the true greatest man of science! Wield the powers of lightning, levitation, rain, sun, and snow to solve physics puzzles and put a stop to Edison's destruction.

Post news Report RSS Particle-Guided Lightning [ Inside Tesla: The Weather Man ]

Lightning is one of the key features in Tesla: The Weather Man, and this article describes our approach to unpredictable lightning with charged particles and pathfinding.

Posted by on

When we decided to make a game about Nikola Tesla fighting robots with weather control powers, the obvious first step was lightning. We wanted something that would look cool and give the satisfaction of striking down your enemies with awesome power, but which could also present a bit of a challenge to control; you shouldn't just be able to instantly hit any enemy anywhere on the screen.

Lightning screenshot

To bring in a puzzle element, we decided most solid objects should block lightning, and we wanted movable obstacles and wires that electricity could travel through. At first we thought about pre-defined nodes for every point lightning could strike, but that seemed to slow down level design and get in the way of the sense of freedom we wanted to create. We decided to step back and look at how lightning works in the real world.

How lightning works

When a sufficient negative charge builds up in clouds, "step leaders" of ionized air begin making paths toward the ground, and at some point the ground reacts by extending "positive streamers" upward. Once any pair of step leader and positive streamer meet, this provides a conduit for rapid exchange of charges, and the transfer generates extreme amounts of heat that produce the light we see1.

To represent this in our game, we decided to emit negatively charged particles from the sky to act as step leaders, and positively charged particles from the ground to act as positive streamers. We allow these particles to pass only through open air and conductive materials, and we cheat a little bit by making them attracted to conductive objects such as metal so that those objects get struck by lightning more often.

Charged particles

Finally, to decide when step leaders and positive streamers meet, we use an A* pathfinding algorithm. Every charged particle or conductive object is a path node, and we create links between nodes that are close enough to each other with no non-conductive objects in the way. This way, lightning doesn't strike until the particles form a fairly steady stream, and never strikes through anything it shouldn't. Since the particles are emitted with some random variance, we get a nicely jagged line when connecting the dots and believably unpredictable timing.

Pathfinding links between particles

We give the player control over the horizontal position the particles are emitted from, as well as the height of the particular ground surface lightning should strike in the case of floating platforms or underground tunnels. This way, the player has a great deal of control in aiming the lightning but still a feeling of volatility as he or she never knows exactly when the lightning will strike or what path it will take.

If you would like to see our lightning in action and more from Tesla: The Weather Man, please check out our trailer below.


Stay tuned for more behind-the-scenes discussions of our game including dynamic water, level painting, and music!

Footnotes:

[1] The description above of how lightning works in the real world is based on John Zavisa's article "How Lightning Works" found at Electrical-contractor.net

Post a comment

Your comment will be anonymous unless you join the community. Or sign in with your social account: