I want to make a simple circuit system in Godot. Here's what I mean by that. (The circuit isn't realistic)

I just want a battery object and a wire object. The batter will supply x amount of power to a wire. Then all the wire can transfer it to other wires to be used with other objects to be implemented later. Here is what I was trying currently:

I had a wire object with an area checking all four sides for things to power. If it can be powered, it powers it with x amount of power. The batter does this to the wires, and the wires do it to other wires. This doesn't work though. The major problem is that when the battery stops powering the wire, the wires power each other.

I can't think of good solution. (Interaction between objects doesn't have to be instant). I also want it be flexible as I want wires to be able to contain other data other than power, but this isn't a necessity and could figure this out myself. Any ideas?

  • 5
    \$\begingroup\$ Most games I know that simulate electricity networks (Factorio, Oxygen Not Included, Rimworld, Satisfactory...) do that by considering each connected graph of wires as as single "electric grid" entity. The electricity distribution mechanic does't care about how much electricity flows through individual wires. It only only cares about the total consumption and production of the entities connected to each grid. Would that work for your game? If not why not? \$\endgroup\$
    – Philipp
    Nov 24, 2023 at 9:46

2 Answers 2


One option is to group all the connected wires into a single logical network that handles distributing power. This has the advantage of being very cheap except when dealing with removing connections that may end up splitting the network or when adding things can join 2 networks.

Another option is to model actual power flow where each wire has an internal energy storage and can pass that energy on to the next wire to equalize everything out. This makes it easier to model the more "realistic" aspects of power management like bottlenecks and distance-based inefficiencies if that is your jam.


tl;dr: model the circuit network as a linear system of equations to easily solve for the current and voltage at every node using off-the-shelf linear algebra software.

It depends how realistic you want the simulation to be. In the real world, wires aren't "supplied power" by a battery, but are actually nodes in a circuit. If you connect a battery to a light bulb with a wire, the wire is more or less just a connection between the light bulb and the battery, so modeling the wire itself isn't important. You "just" have to keep track of which circuit elements are connected to which others. Of course, this analogy eventually breaks down at a certain level of realism.

As mentioned by others, the easiest way to model this is to pretend that all connected wires are a single node, and all circuit elements connected to that node are effectively connected directly to one another.

If you want to model actual power flow through the circuit, you have to start thinking of the wires themselves as elements in the circuit. A light bulb has a certain resistance, which means that, given some voltage across its terminals, some amount of current will flow through it. The amount of current is described by Ohm's Law: I (current) = V (voltage) / R (resistance). Wires also have resistance-- it's just that the resistance is usually very small.

Once you start modeling the network this way, you can do other interesting things. For example, you may want to specify a maximum amount of current that a wire can supply without breaking. The amount of power dissipated in a resistor (or light bulb or wire or anything with resistance) in watts is P = I^2 * R = V^2 / R. The more power dissipated, the hotter the wire gets. You could give the maximum current directly (as is done for various wire gauges in the real world), or even model the temperature of the wires themselves (see below, as this is a bit of a tangent).

It may seem impossible to calculate the voltages and currents through a huge network of wires and resistive circuit elements this way, but it's actually possible to reduce the network to a system of linear equations. There exists free software which can solve these systems extremely quickly and efficiently and, once done, gives you the current and voltage through every node, not matter how the circuit is arranged. You can use this information to determine if your battery is powerful enough to power your circuit, whether or not to blow up or melt wires that are carrying too much current, etc.

You may also want to model the equivalent series resistance (ESR) of your battery. The more current the battery has to supply, the weaker the measured voltage of the battery will be. You can think of the ESR as like a resistor inside the battery before you can connect to its terminals. Adding this resistor to your system of equations will model that weakness effectively for free.

There are other factors that you could model if you really wanted to, like parasitic inductance and capacitance, reactive power and power factor (particularly important for industrial applications like factories), the skin effect, and many other electrical engineering details that wouldn't really contribute to gameplay for anyone but power engineering nerds like me :)

To model the temperature increase from dissipated power, you need the heat capacity for that substance. This describes the amount of energy required to raise the temperature of a given mass of that substance by some number of degrees. For example, the specific heat of aluminum is 0.89 J/g °C, which means that every joule of energy dissipated will increase the temperature of one gram of that substance by one degree Celsius. A watt is one joule per second, so dissipating 1 kW through a 1 kg wire for 60 seconds will increase the temperature by (1000 J/s)*(60 s)/(0.89 J/g °C)/(1000 g) = 67.42 °C.

Of course this is complicated further by modeling how that wire will transfer the thermal energy away as it is heating, so it's probably not modeling the wire to this level unless you're really interested :)

  • \$\begingroup\$ For data transmission using the "connected wires are the same network node" approach is more than enough. I go into the resistive modeling approach because you specifically mention specific amounts of power flowing through wires. \$\endgroup\$
    – Zac Crites
    Nov 24, 2023 at 18:31
  • \$\begingroup\$ Thank you a lot. This is more than I asked for (This is a good thing), and this information may come in handy. \$\endgroup\$ Nov 25, 2023 at 20:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .