Cable Component

A breakdown of the Cable Component.

Choose your operating system:

Windows

macOS

Linux

CC_InGame.png

Having the ability to cheaply add cables, ropes, or chains that can sway back and forth as if being gently blown by the wind can add a nice bit of life to your Unreal Engine 4 (UE4) projects. In the following document, we will take a look at how you can use the Cable Component plugin to create, setup and control how the cables look, react and even collide with objects in your levels.

Simulation and Rendering

To perform the actual cable simulation, a technique called Verlet Integration , which is well known in game development. The idea is to represent the cable as a series of particles, with distance constraints between them. The particles at the ends are fixed , moving with whatever they are attached to. The ones in the middle are free , falling with gravity. For each step, you update the velocity and position of each particle, and then move them to satisfy the constraints. The stiffness of the cable is controlled by the number of times we iterate to enforce the constraints (each step).

Click for full image.

Now that there is a nice chain of connected particles bouncing around, they need to be rendered. To render a cable, a class called FCableSceneProxy was created to represent the render of the cable. Each end of the Sim particles' positions (done on the main thread, inside of TickComponent) are then passed to this proxy via the SendRenderDynamicData_Concurrent function. Next, update is locked on the render thread, and then the index and vertex buffers are updated, thereby making a tube mesh. For each vertex on this tube mesh, we need to calculate a position, a Texture UV, and three Tangent Basis vectors. When doing this, X will point along the cable, Z will point straight out from the cable (the normal) and Y is perpendicular to X and Z . These properties have been exposed to the components, giving you the ability to control the number of sides, the radius of the tube, and how many times the UVs can tile along the cable.

Click for full image.

Enabling the Plug-in

By default, the Cable Component plugin should be enabled. However, if it is not, you can enable it by first going to the main toolbar and selecting Edit > Plugins . Then, from the plugins list, go to Rendering and make sure the Cable Component has a checkmark in the box next to Enabled .

Click for full image.

Using the Cable Component

You can add Cable Components to your projects levels in two different ways. In the following section, we will go over the two different ways that you can add cables to your project's levels.

Using Cable Components from the Place Actors Pannel

To use the Cable Component from the Place Actors Panel, you will need to do the following:

  1. First, make sure that the Place Actors panel is visible, and then in the Search Classes box, input the word Cable .

    CC_Find_In_Modes.png

  2. To add the Cable Actor to the world, click on the Cable Actor in the Place Actors panel and then drag it into the level.

    Click for full image.

  3. You can now position, rotate, and scale the Cable Actor so that it fits the needs of your level.

Using Cable Component in Blueprints

To use the Cable Component in your Blueprints, you will need to do the following:

  1. First, create a new Blueprint called BP_Cable and make sure that it uses Actor as the parent class.

    CC_MakeNewBP.png

  2. Next, from the Components section of the BP_Cable Blueprint, click on the Add Component button and then locate the Cable component in the list. When located, click on it to add it to the Components list.

    CC_Add_CC.png

  3. With the Cable Component now added, select the Cable component in the components list, so that you can adjust its properties via the Details panel. For now, leave everything as the default and make sure to Compile and Save your Blueprint.

    CC_Cable_Options.png

    To make either side of the cable fall, un-check the Attach Start or Attach End option the Details panel of the Cable Component. This can also be toggled while the game is running to go along with effects.

  4. Locate your Cable Blueprint in the Content Browser , and then drag it into the level. Once placed, you can use the move and rotate tools to position it as needed.

    Click for full image.

Attaching Objects to the Cable ends

You can also attach objects to either end of the cable so that the objects will swing along with the cable. To accomplish this in your UE4 projects, all you need to do is the following:

  1. You will first need to add a Cable Actor and a Static Mesh to the level.

    Click for full image.

    Make sure that the Static Mesh that you are attaching to the end has its Mobility set to Moveable .

  2. Locate the Static Mesh you want to attach to the end of the Cable Actor in the World Outliner, and then drag it on top of the Cable Actor. After doing this, the following input window will be displayed.

    Click for full image.

  3. Select the Cable End option, and in the viewport, you should see your Static Mesh snap to the end of the Cable Actor.

    Before

    After

  4. Now, select the Cable Actor in the level. Then, in the Details panel under the Cable section, uncheck the Attach End box.

    Click for full image.

    Note that you do not have to only use the Attach Start and Attach End option to attach cables to Actors. You can also specify a Socket that can be used as the attachment point.

  5. After doing this, the cable should now swing freely in the viewport.

    Note that you can dynamically toggle the Attach Start and Attach End bools at run time, which can make for some interesting effects.

Collision and Stiffness

Enabling Collision and Stiffness will greatly increase the cost of the Cable Actor. Only enable these features if the cable has to collide with something in the world, or if the cable needs some stiffness to help make the effect look better. If none of that is needed, it is best to keep these options disabled to save performance.

The Cable Component does have the option to have the cable collide with the world, controlling how stiff the cable is. To enable this functionality, you will need to do the following:

  1. First, in the Details of the Cable Component under the Cable section, press the small white triangle to expose the advanced rollout option.

    CC_Advanced_Options.png

  2. Check both the Enable Stiffness and Enable Collision options to enable these features.

    Click for full image.

  3. Now, when you move the Cable Actor around, or if an object collides with, the Cable Actor the cable should collide with the object that it comes in contact with.

Property Breakdown

The following table breaks down each of the properties on the Cable Component:

Cable

CC_Cable_Properties.png

Property Name

Description

Attach Start

Should we fix the start to something, or leave it free. If false, component transform is just used for initial location of the start of cable.

Attach End

Should we fix the end to something (using AttachEndTo and EndLocation), or leave it free. If false, AttachEndTo and EndLocation are just used for initial location of end of cable.

Attach End To

Actor or Component that defines the end position of the cable.

Component Property

Name of component property to attach the cable to.

Attach End To Socket Name

Socket name on the AttachEndTo component to attach to.

End Location

End location of cable, relative to AttachEndTo (or AttachEndToSocketName) if specified, otherwise relative to cable component.

Cable Length

Rest length of the cable.

Num Segments

How many segments the cable has.

Solver Iterations

The number of solver iterations controls how 'stiff' the cable is.

Substep Time

Controls the simulation substep time for the cable.

Enable Stiffness

Add stiffness constraints to cable.

Enable Collision

Perform sweeps for each cable particle at each substep, to avoid collisions with the world. Uses the Collision Preset on the component to determine what is collided with.This greatly increases the cost of the cable simulation.

This is currently Experimental.

Cable Forces

CC_CableForces_Properties.png

Property Name

Description

Cable Forces

Force vector (world space) applied to all particles in cable.

Cable Gravity Scale

Scaling applied to world gravity affecting this cable.

Cable Rendering

CC_CableRendering_Options.png

Property Name

Description

Cable Width

How wide the cable geometry is.

Num Sides

Number of sides of the cable geometry.

Tile Material

How many times to repeat the material along the length of the cable.

Additional Reference

The following section sends you to an external reference, where you can read more about the inspriration behind cable components. To read more about Verlet Integration , check out the following paper from Thomas Jakobsen:

Help shape the future of Unreal Engine documentation! Tell us how we're doing so we can serve you better.
Take our survey
Dismiss