Solar Panels in BGE/UPBGE

Unfortunately there is not an easy solution. If a binary “yes/no” is good enough, you could consider making a physics shape that approximates the lit area and detecting collisions with that.

If this is just for a simple game-mechanic, don’t overthink it. If it’s a simulation of something, you may have to go a lot further.

So what is the game mechanic you are trying to implement?


Beyond that you will need python - and even then, it will be an approximation. You can get the lights intensity and then measure the distance to calculate the attenuation, and from that make a guess at the solar panels energy output. A more advanced solution may a raycast to estimate shadowing. An even more advanced one could use multiple rays distributed across the object, possibly using monte-carlo sampling to get a more accurate estimation over time. It all depends on how accurate the simulation of a solar panel needs to be.

Once upon a time I did a rather unplayable game that computed the light falling on a surface to estimate the pressure of solar wind on an awkward-shaped object. It wasn’t easy, but here it is. It did it “backwards” - using a camera in the position of the light, and for that render-pass, setting all the materials to black except the object of interest. This only worked for a single object, but it was fine for the game.