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()