Files
RCBASIC4/doc/files/createhingeconstraintex.txt
2026-02-26 15:33:51 -06:00

25 lines
1.2 KiB
Plaintext

#title CreateHingeConstraintEx [RCBasic Doc]
#header Function CreateHingeConstraintEx( actorA, actorB, frameA, frameB, useReferenceFrameA)
Simulates a hinge joint, which allows two actors (or an actor and the world) to rotate around a single axis while restricting movement along the other axes. This is similar to the way a door swings on its hinges or how an elbow joint functions in the human body.
#code
actorA = CreateCubeActor(100) 'Creates a cube actor
frameA = DimMatrix(4, 4) 'A transform matrix must be a 4x4 matrix
SetIdentityMatrix(frameA, 4) 'Sets frameB to a 4x4 identity matrix
SetMatrixTranslation(frameA, 0, 1, 0) 'Sets the attach point of the constraint to the top of the cube
actorB = CreateCubeActor(100) 'Creates a cube actor
frameB = DimMatrix(4, 4) 'A transform matrix must be a 4x4 matrix
SetIdentityMatrix(frameB, 4) 'Sets frameB to a 4x4 identity matrix
SetMatrixTranslation(frameB, 0, 1, 0) 'Sets the attach point of the constraint to the top of the cube
hinge = CreateHingeConstraint(actorA, actorB, frameA, frameB, true)
#/code
Note: It is recommended to use CreateHingeConstraintEx() in most cases
#ref CreateHingeConstraint SetIdentityMatrix SetMatrixTranslation SetMatrixRotation