How to make expandable cable?

To be more specific, I was asked to make a ‘game’ that lets you build a computer, and my question is, how to get an optimized cable length by adding a little gravity to not to be that unrealistic solid cable and as the inspector drags the end of the cable, the length can expand to a specific length. For example to be simple: from the wall plug to the PSU you can have a cable and it can be 10 cm long or even 1000 m if you wish so. If it is a bit unclear then I will try to specify a bit more. Thank you guys in advance!

I presume that you’re asking in 3D way.
But it’s not easy to perceive your concept.
Do you want to apply physics effect on the cable or you’re talking about some kidn of code reel?

Variable should be…

Input value from the player character,
Location vector of player’s original location that started to input ( dragging or else )
Location vector for current location that current value ( how much did you drag )

then you should calculate those 3 value then you can figure it out the length of the code, on depend how much did you input (drag or else…)

Then, I can tell you 3 different way for length manipulation.
One is with the vertex shader, It’s much faster and cheap because you’re literally changing object meshe’s vertex, also UV coordination’s repeating for the prevent stretching.

Second is changine component scale value also UV coordination repeating as I told.

The other way is just attaching a same cable object to the end of the cable, and it’s gonna cost quite expensive and slow if you use multiple value for length (like 100x measurement)

and if you mentioned about physics, it should be APEX plugin then I need to talk about only in Maya (because I only use maya for physX)…

I’ll keep listining . Good luck!

Sou you tell me I am able to create ‘infinite’ length cable by dragging it? The suspension part is only a side quest for me, to apply a bit of gravity. The main question is to have a cable with two ends, if I drag one of the ends it expands and if I take one end to the other it shortens!

Thank You for your fast response, sadly I am a bit new to UE4 and I’m more trained with 3DSMax which contains the same physx. The first solution seems reasonable since it wont spam with poly amount killing the hardware. The cable would be a of course plastic covered, maybe solid color so it doesnt matter if stretching.

AH!!! I remember long ago, my mathematics professor gave a lecture on this very topic! Suppose you have a cable suspended between two towers (such as a powerline). What kind of function would best model the curvature of that suspended cable, with the forces of gravity applied to it? The answer of course, is a Hyperbola! As far as specific equations go, you’re on your own. This is just the direction I’d go in with your engineering problem.

well… you can’t get ‘infinite’ length cables because your computer doesn’t have infinite memory. But yes, you could get cables of arbitrary lengths. If you use the hyperbolic equations, you can create a parabola (or hyperbola, whichever is easier). I’d do this computation within the construction script for your cable. The variable inputs are going to be the end points which suspend your cable and the amount of ‘slack’ you give to your cable. The more slack, the more curvature you get.

Yes the infinite length was just an example but true, since I am not very familiar with UE4 yet I accept any constructive answers, I will try to learn BP as fast as possible! :smiley:

Yes, good idea! There’s a blueprint section within the “Content Examples” demo which shows how to use a construction script. They have a section in there where they dynamically create a white picket fence of arbitrary length using the construction script. You’d be very interested in that particular section. You can use that as a starting point to create your cable (similar technique). I’d just find a mathematical equation which accurately models the cable with its tension. This equation can then give you any number of points along that cable, and then you can draw connected lines along these points to represent your cable with its tensile curvature.

And what grants that the cable will be smooth and wont tangle? How could be an algorythm like that can be created?

Uh… that’s a very different type of question from modelling a suspended cable between two points, but they share the same underlying model… If you want to model a cable or rope, or any sort of string, you can divide it up into very very small sections. Then, you can apply a constraint on how much each section can ‘bend’ relative to its preceding section, via some angle value. You would then define the bendability of the cord with some fixed constant which represents the maximum bendable constraint. A piece of string could bend 360 degrees at any point, but a power cable cannot. I imagine that there’s a white paper out there which you can google which gives a much better scientific model. (don’t google “String Theory”, wrong subject)

Well you already answered my question which I am very grateful for! :smiley: Thank you and continue throwing solutions! :slight_smile: