# Electric Pole like system

**URL:** <https://forums.unrealengine.com/t/electric-pole-like-system/458599>\
**Category:** Blueprint\
**Tags:** flow-control, unreal-engine, Blueprint, question\
**Created:** [November 19, 2019, 12:16pm UTC](https://forums.unrealengine.com/t/electric-pole-like-system/458599 "2019-11-19T12:16:06Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Edriel](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Edriel](https://forums.unrealengine.com/u/Edriel)\
**Post date:** [November 19, 2019, 12:16pm UTC](https://forums.unrealengine.com/t/electric-pole-like-system/458599/1 "2019-11-19T12:16:06Z")

</div>

Hey guys!

I’m struggling quite a bit trying to make an “electric-pole-like” system.  
What I want to achieve is the same as the said system:  
I have an actor generating energy and “pole-actors” making that energy flow between them.

Problem is when I have those poles disconnected with each other.

![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/1/7/c177f7dc25f4cd0e3d6970d894d9cba97d7a5b96.jpeg)

Looking at picture B, I have pole 2 and 3 still generating energy and I don’t know how to handle this.

Can anyone help me please?  
Much appreciated

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [November 19, 2019, 12:24pm UTC](https://forums.unrealengine.com/t/electric-pole-like-system/458599/2 "2019-11-19T12:24:43Z")

</div>

Is this a BP, can we see it?

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [November 19, 2019, 12:26pm UTC](https://forums.unrealengine.com/t/electric-pole-like-system/458599/3 "2019-11-19T12:26:08Z")

</div>

You need to let a pole have energy only when

1. It is connected to the generator

or

1. It is connected to a pole that is (… ) to the generator.

---

<div class="post-metadata">

**Author:** ![Edriel](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Edriel](https://forums.unrealengine.com/u/Edriel)\
**Post date:** [November 19, 2019, 1:42pm UTC](https://forums.unrealengine.com/t/electric-pole-like-system/458599/4 "2019-11-19T13:42:56Z")

</div>

Let’s say I have a boolean “ConnectedToGenerator”.  
In picture A, I have all of the variables set to True, but if I disconnect 1 from 2 (like in picture B), how can I set both 2 and 3 to False?

Subsequent communications between BPs is the problem:

since 2 communicates with 1 and “sees” that it is disconnected but also it communicates with 3, it “sees” that it is connected and so it thinks it is indeed connected to the generator when it is not.

It’s kinda hard to explain exactely my problem though 😕  
It seems easy but it is not, or at least not for me.

I have no BPs to show as I tried a LOT of times with no success so I need to have a real solution before starting up again.

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [November 19, 2019, 3:15pm UTC](https://forums.unrealengine.com/t/electric-pole-like-system/458599/5 "2019-11-19T15:15:54Z")

</div>

Like this. A node only has power if it is connected to the generator or it is connected to another node with power.

So it never looks further than it’s neighbour.

This works.

---

<div class="post-metadata">

**Author:** ![Tuerer](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/tuerer/32/1008648_2.png) [@Tuerer](https://forums.unrealengine.com/u/Tuerer)\
**Post date:** [November 19, 2019, 3:32pm UTC](https://forums.unrealengine.com/t/electric-pole-like-system/458599/6 "2019-11-19T15:32:26Z")

</div>

It’s a really complex problem, I can tell you that. I struggled with a very similar one once, and I might be able to help you, but I need to know a few conditions:

1. Can multiple Poles be connected to a single Generator at the same time, or are they only powered in a chain?

2. Can there be more than one generator in a level to be able to ultimately power one Pole from two or more Generator at the same time?

3. How exactly are Poles get powered up? Is it based on their proximity to a power source or are there some other event that turn them on?

---

<div class="post-metadata">

**Author:** ![Edriel](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Edriel](https://forums.unrealengine.com/u/Edriel)\
**Post date:** [November 19, 2019, 3:59pm UTC](https://forums.unrealengine.com/t/electric-pole-like-system/458599/7 "2019-11-19T15:59:09Z")

</div>

That’s why I couldn’t figure that out then.  
To answer your questions:

1. Every generator can have up to 4 connections, same as the poles.

2. Yes there can be multiple generators in a level and multiple generators can “energize” a pole.  
Also generators can be connected to each other.

3. Ideally I’d like generators to send power to a conductor (an electrical cable for example) which then sends power to the pole which then sends that power to all other connections.  
But I don’t mind an easier or more straight solution if it solves the problem.

Cheers

---

<div class="post-metadata">

**Author:** ![Tuerer](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/tuerer/32/1008648_2.png) [@Tuerer](https://forums.unrealengine.com/u/Tuerer)\
**Post date:** [November 19, 2019, 5:58pm UTC](https://forums.unrealengine.com/t/electric-pole-like-system/458599/8 "2019-11-19T17:58:53Z")

</div>

Okay, frankly, the more I think of it, the more difficult it gets. The closest thing to this was implemented in recent Trine 4, but idk how they did it.

One thing that comes to mind is that you can recalculate everything every time a disconnection happens. Like, if you disconnect one pole, you set every pole’s Connected bool to False and immediately recalculate starting from the generators. If you don’t have hundreds of poles, it won’t be noticeable.

Because if you want to do it the “proper” way and only disable the ones that have to be disabled, it might be even more expensive than that.

Sorry I couldn’t help more.

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [November 19, 2019, 6:49pm UTC](https://forums.unrealengine.com/t/electric-pole-like-system/458599/9 "2019-11-19T18:49:59Z")

</div>

I think you have to be very clear about exactly how you want it to work, otherwise you’ll never get there. Also, what can you limit? For instance it would really help if the poles have one input and 3 outputs, for instance.

That way a pole can only give power on it’s outputs if it has power itself.

If you just try and connect them in a web it will be like a kind of ‘travelling salesman’ nightmare…

---

<div class="post-metadata">

**Author:** ![Edriel](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Edriel](https://forums.unrealengine.com/u/Edriel)\
**Post date:** [November 19, 2019, 8:52pm UTC](https://forums.unrealengine.com/t/electric-pole-like-system/458599/10 "2019-11-19T20:52:12Z")

</div>

I have a “kinda” working method but it doesn’t really do what it needs to do:

[Project video](https://i.imgur.com/UKFjpBT.mp4)

Basically if you see the last two Nodes (green and red) the green energy is flowing too slow since it’s just 1 “ten-generator” against many green generators.

The energy spreads evenly between Nodes (generators, conductors, poles etc.), but the last bit the energy should flow only in the “red direction”.  
This is caused by a “never-ending” gain/lose energy situation.  
The only thing that makes this not a loop is just because the Conductors/Nodes sends their excessive energy to the next not-full Conductor/Node.

It’s kinda complicated to explain in words.

Anyway that’s why I wanted to try the “connected” solution but as you said it seems like it’s complicated as well but I actually didn’t try to do what you said as I think it will take a huge impact on performances but at this point I think I could try and see how it goes.

If you have a solution to my other “kinda-working” method (if you understood how it works) please let me know.

In the meanwhile thank you very much for the help.

I also want to thank @ClockworkOcean for his last suggestion.  
If everything goes wrong I might take into consideration your I/O solution.

---

<div class="post-metadata">

**Author:** ![koda](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/koda/32/692574_2.png) [@koda](https://forums.unrealengine.com/u/koda)\
**Post date:** [November 22, 2019, 5:42pm UTC](https://forums.unrealengine.com/t/electric-pole-like-system/458599/11 "2019-11-22T17:42:13Z")

</div>

This is a pretty Interesting question. It might help to read a little about data structures, specifically binary trees and linked lists. It won’t be an exact answer since the number of inputs and outputs that you want may vary. Think about a node (or pole) as a single entity first. The node has to identify whether it is attached to a parent, and whether it has child nodes down stream.

Each node A) keeps a reference to the child beneath it, B) has the same state as its parent node and C) is marked as a root node (generator) or not.

When a node is detached from its parent, if it is not a generator, you trigger an event or function that traverses through the lower nodes and updates the pole states.

Sorry if that’s a bit too technical. I’m interested to see where you go with this. I might try it out later if I have time and update.
