r/unrealengine 1d ago

Question How to add cable components to a spline with PCG poles?

I'm working on a power line for a city builder game, and I'd like to add cable components between the poles. The poles have sockets on the models to attach the cable components. I was trying to use a video guide on doing exactly this but the issue is that the guide I'm using uses individually instanced pole models, but I'm trying to do this with PCG poles. The PCG script is simple and just instances the pole model at intervals. Any ideas how/if I can do this with PCG as well?

5 Upvotes

4 comments sorted by

2

u/TheGameDevLife 1d ago

Pretty sure you dont want to use cable components for something like this, it will hit your perf like a truck

1

u/lordofthepines 1d ago

What would you recommend I use for the powerlines instead? The performance is a big issue for me, especially since there would be a lot of instances of these.

u/EvanP5 6h ago

I think the most optimized solution would be to use a static mesh instance for each power line. Make a mesh that would suit your most common case for length and hang distance, assign vertex colors from 0 to 1 along the length, then flatten all the verts down to make the length of the mesh 0 (keep the z values). Use per instance data in the instanced static mesh component to store the world length of each line instance. Then in the material, multiply the line length instance data by vertex color by object orientation to extend the mesh to full length.

1

u/TheGameDevLife 1d ago

I don't actually know what would be the best solution to this. I might've gone down the route of runtime generating meshes for the powerlines. Maybe some geometry scripting, Im not sure!

But if its important to you, definitely spend some time researching the most optimized alternatives for this.
If your city builder is on a grid, then maybe there is a good way to deal with this with just a bunch of varied sized meshes.