CreateJoint

Constructor:

CreateJoint(targetPart, jointType)

Description

Creates a physical constraint between one object and another. The anchor position of the created physical constraint defaults to the pivot of the two objects.

Parameters

Variable name Type Default Description
targetPart RWObject Target object
jointType Enum.JointType Joint type

Return Value

Type Description
RWObject The created constraint object

Examples

Create parts and a constraint between them.

local p1 = RWObject.Create("Part") -- create a part
local p2 = RWObject.Create("Part") -- create a part
p1.Name = "p1" -- set the part1 name as p1
p1.Position = Vector3.New(0,10,0) -- assign a vector to the position of p1
p2.Name = "p2" -- set the part2 name as p2
p2.Position = Vector3(0,20,0) -- assign a vector to the position of p2
local joint1 = p1:CreateJoint(p2,JOINT_TYPE.SplitJoint) -- constrain part1 and part2 in the form of SplitJoint