Skip to main content
Version: latest - a1.7.0 ⚖️

⛓️ Cable

A Cable represents a Physics Constraint which joins two Actors with a rope-like visual representation between them

info

🟦 Authority: This class can only be spawned on Server.

Inheritance: This class inherits from Actor and Paintable.

nanos world 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().

After attaching the two sides of your cable, the physics can be tweaked to affect how the constraint will affect the objects.

tip

Cables are automatically destroyed when one of the sides are detached

tip

You can find more useful information regarding physical properties of the joint in the end of this page.

Usage

Server/Index.lua
local my_cable: = Cable()
local cube_01 = Prop(Vector(100, 100, 100), Rotator(), "nanos-world::SM_Cube")
local cube_02 = Prop(Vector(200, 0, 100), Rotator(), "nanos-world::SM_Cube")

my_cable::AttachStartTo(cube_01)
my_cable::AttachEndTo(cube_02)

Constructor Parameters

TypeNameDefaultDescription
VectorlocationVector(0, 0, 0)
booleanenable_visualstrueToggles the cable visuals

Functions

Inherited Paintable Functions
ReturnsNameDescription
SetMaterialSets the material at the specified index of this Actor
SetMaterialFromWebUISets the material at the specified index of this Actor to a WebUI object
SetMaterialFromSceneCaptureSets the material at the specified index of this Actor to a SceneCapture object
ResetMaterialResets the material from the specified index to the original one
SetMaterialColorParameterSets a Color parameter in this Actor’s material
SetMaterialScalarParameterSets a scalar parameter in this Actor’s material
SetMaterialTextureParameterSets a texture parameter in this Actor's material to an image on disk
SetMaterialVectorParameterSets a Vector parameter in this Actor’s material
SetPhysicalMaterialOverrides this Actor's Physical Material with a new one
ReturnsNameDescription
AttachStartToAttached the beginning of this cable to another Actor at a specific bone or relative location
AttachEndToAttached the end of this cable to another Actor at a specific bone or relative location
DetachEndDetaches the End of this Cable
DetachStartDetaches the Start of this Cable
SetAngularLimitsSets the Physics Angular Limits of this cable
SetLinearLimitsSets the Physics Linear Limits of this cable
SetCableSettingsSet the overall settings for this cable (visuals only)
SetForcesSet the forces the cable has applied (visuals only)
SetRenderingSettingsSet the rendering settings of this cable (visuals only)
SetLocationSets the actor's location in the game world
GetLocationGets the actor's location in the game world
GetAttachedStartToGets the actor’s attached to Start of this Cable
GetAttachedEndToGets the actor’s attached to End of this Cable

AttachStartTo

Attached the beginning of this cable to another Actor at a specific bone or relative location

my_cable:AttachStartTo(other, relative_location, bone_name)
TypeParameterDefault ValueDescription
Actorother
Vectorrelative_locationVector()
stringbone_name``

AttachEndTo

Attached the end of this cable to another Actor at a specific bone or relative location

my_cable:AttachEndTo(other, relative_location, bone_name)
TypeParameterDefault ValueDescription
Actorother
Vectorrelative_locationVector()
stringbone_name``

DetachEnd

Detaches the End of this Cable

my_cable:DetachEnd()

DetachStart

Detaches the Start of this Cable

my_cable:DetachStart()

SetCableSettings

Set the overall settings for this cable (visuals only)

my_cable:SetCableSettings(length, num_segments, solver_iterations)
TypeParameterDefault ValueDescription
numberlengthRest length of the cable
numbernum_segmentsHow many segments the cable has
numbersolver_iterationsThe number of solver iterations controls how 'stiff' the cable is

SetForces

Set the forces the cable has applied (visuals only)

my_cable:SetForces(force, gravity_scale)
TypeParameterDefault ValueDescription
VectorforceForce vector (world space) applied to all particles in cable
numbergravity_scale1Scaling applied to world gravity affecting this cable

SetAngularLimits

Sets the Physics Angular Limits of this cable

my_cable:SetAngularLimits(swing_1_motion, swing_2_motion, twist_motion, swing_1_limit, swing_2_limit, twist_limit)
TypeParameterDefault ValueDescription
ConstraintMotionswing_1_motionIndicates whether the Swing1 limit is used
ConstraintMotionswing_2_motionIndicates whether the Swing2 limit is used
ConstraintMotiontwist_motionIndicates whether the Twist limit is used
numberswing_1_limitAngle of movement along the XY plane. This defines the first symmetric angle of the cone
numberswing_2_limitAngle of movement along the XZ plane. This defines the second symmetric angle of the cone
numbertwist_limitSymmetric angle of roll along the X-axis

SetLinearLimits

Sets the Physics Linear Limits of this cable. If use_soft_constraint is enabled, then stiffness and damping will be used, otherwise restitution will be used.

my_cable:SetLinearLimits(x_motion, y_motion, z_motion, limit, restitution, use_soft_constraint, stiffness, damping)
TypeParameterDefault ValueDescription
ConstraintMotionx_motionIndicates the linear constraint applied along the X-axis. Free implies no constraint at all. Locked implies no movement along X is allowed. Limited implies the distance in the joint along all active axes must be less than the Distance provided
ConstraintMotiony_motionIndicates the linear constraint applied along the Y-axis. Free implies no constraint at all. Locked implies no movement along Y is allowed. Limited implies the distance in the joint along all active axes must be less than the Distance provided
ConstraintMotionz_motionIndicates the linear constraint applied along theZX-axis. Free implies no constraint at all. Locked implies no movement along Z is allowed. Limited implies the distance in the joint along all active axes must be less than the Distance provided
numberlimitThe distance allowed between between the two joint reference frames. Distance applies on all axes enabled (one axis means line, two axes implies circle, three axes implies sphere)
numberrestitution0Controls the amount of bounce when the constraint is violated. A restitution value of 1 will bounce back with the same velocity the limit was hit. A value of 0 will stop dead
booleanuse_soft_constraintfalseWhether we want to use a soft constraint (spring)
numberstiffness0Stiffness of the soft constraint. Only used when Soft Constraint is on
numberdamping0Damping of the soft constraint. Only used when Soft Constraint is on

SetRenderingSettings

Set the rendering settings of this cable (visuals only)

my_cable:SetRenderingSettings(width, num_sides, tile_material)
TypeParameterDefault ValueDescription
numberwidthHow wide the cable geometry is
numbernum_sidesNumber of sides of the cable geometry
numbertile_materialHow many times to repeat the material along the length of the cable

GetAttachedStartTo

Gets the actor attached to Start

Returns any

entity:GetAttachedStartTo()

GetAttachedEndTo

Gets the actor attached to End

Returns any

entity:GetAttachedEndTo()

Events

Inherited Actor Events
NameDescription
DestroyTriggered when an Actor is destroyed
SpawnTriggered when an Actor is spawned/created
ValueChangeTriggered when an Actor has a value changed with :SetValue()