Cable
HELIX Cables are composed primarily of two Unreal Engine components: a Cable and a PhysicsConstraint. The first is used for visual purposes only and the second one gives the effective physical effects that are applied to each end of the Cable.
Info
Cable visuals can be tweaked with :SetForces(), :SetCableSettings() and :SetRenderingSettings() methods. Those methods don’t have effect on the physics being applied and only have effects on the visual representation.
Cable physics can be tweaked with :SetAngularLimits() and :SetLinearLimits().
Example#
local CableActor = Cable(Vector(0.0, 0.0, 60.0), true)
local Cube1 = StaticMesh(Vector(52.684121, -37.863267, 92.023095), Quat(180, 0, 0, 1), '/Engine/BasicShapes/Cube.Cube', true)
local Cube2 = StaticMesh(Vector(44.109754, -534.058274, 91.712091), Quat(0, 180, 0, 1), '/Engine/BasicShapes/Cube.Cube', true)
CableActor:AttachStartTo(Cube1, Vector(0, 0, 0), '')
CableActor:AttachEndTo(Cube2, Vector(0, 0, 0), '')
Variables#
| Name | Type |
|---|---|
| CableComponent | UCableComponent |
| PhysicsComponent | UPhysicsConstraintComponent |
Constructor#
- returns:
table
local CableActor = Cable(Vector(0.0, 0.0, 60.0), true)
print(CableActor.Object) -- AActor
print(CableActor.CableComponent) -- UCableComponent
print(CableActor.PhysicsComponent) -- UPhysicsConstraintComponent
| Type | Name | Default | Description |
|---|---|---|---|
| Vector | StartLocation |
The start location of the cable, this gets overridden upon attachment. | |
| boolean? | bEnableVisuals |
true |
Whether the cable actor is visible |
Functions#
AttachStartTo#
Attaches the start of a cable to another actor
- TargetActor
Actor: The actor to attach to. - RelativeLocation
Vector: Local offset from the attach point. - Socket
string: Optional socket name. - returns:
boolean
local success = CableActor:AttachStartTo(TargetActor, RelativeLocation, Socket)
AttachEndTo#
Attaches the end of a cable to another actor
- TargetActor:
Actor— the actor to attach the end to - RelativeLocation:
Vector— local offset from the attach point - Socket:
string— optional socket name on the target
CableActor:AttachEndTo(TargetActor, RelativeLocation, Socket)
DetachEnd#
Detaches the end of the cable from the actor
CableActor:DetachEnd()
DetachStart#
Detaches the start of the cable from the actor
CableActor:DetachStart()
SetCableSettings#
Sets the cable settings, like length
- Length:
number— rope length in Unreal units - Segments:
number— visual segment count (smoothness vs. cost) - SolverIterations:
number— extra solver passes for stability/quality
CableActor:SetCableSettings(Length, Segments, SolverIterations)
SetForces#
Sets the vector of force to be applied to all particles in the cable
- Force:
Vector— constant world-space force per particle - GravityScale:
number— multiplier for rope gravity (e.g.,0.5is lighter)
CableActor:SetForces(Force, GravityScale)
SetAngularLimits#
Sets the angular limits for the cable
- Swing1Motion:
ConstraintMotion—Free,Limited, orLocked - Swing2Motion:
ConstraintMotion—Free,Limited, orLocked - TwistMotion:
ConstraintMotion—Free,Limited, orLocked - Swing1LimitAngle:
number— degrees, only used when motion isLimited - Swing2LimitAngle:
number— degrees, only used when motion isLimited - TwistLimitAngle:
number— degrees, only used when motion isLimited
CableActor:SetAngularLimits(Swing1Motion, Swing2Motion, TwistMotion, Swing1LimitAngle, Swing2LimitAngle, TwistLimitAngle)
SetLinearLimits#
Sets the linear limits for the cable
- XMotion:
ConstraintMotion—Free,Limited, orLocked - YMotion:
ConstraintMotion—Free,Limited, orLocked - ZMotion:
ConstraintMotion—Free,Limited, orLocked - Limit:
number— distance limit used when motion isLimited - Restitution:
number— bounciness when hitting the limit - bUseSoftConstraint:
boolean— enables spring-like behavior - Stiffness:
number— spring stiffness when soft constraint is enabled - Damping:
number— spring damping when soft constraint is enabled
CableActor:SetLinearLimits(XMotion, YMotion, ZMotion, Limit, Restitution, bUseSoftConstraint, Stiffness, Damping)
SetRenderingSettings#
Sets the rendering settings for the cable
- Width:
number— rope thickness in Unreal units - NumberOfSides:
number— cylinder sides (visual smoothness) - TileMaterial:
number— material tiling along the rope
CableActor:SetRenderingSettings(Width, NumberOfSides, TileMaterial)
GetAttachedStartTo#
Gets the actor that the start of the cable is attached to
- returns: Actor
CableActor:GetAttachedStartTo()
GetAttachedEndTo#
Gets the component referenced that the end of the cable is attached to
- returns: FComponentReference
CableActor:GetAttachedEndTo()