UltimateRope
A class in Root.Township, the global namespace.
Third-party Ultimate Rope Editor component: builds a physics rope from jointed rigidbody links (procedural mesh, linked objects or imported bones), with optional coil and extension. Runs in edit mode too.
- Listed in Global namespace: T to X
- Inherits or implements
MonoBehaviour - Nested types
EAxis,EColliderType,ERopeExtensionMode,ERopeType,RopeBone,RopeBreakEventInfo,RopeNode - Attributes
ExecuteInEditMode
Constructors
| Member | What it is |
|---|---|
UltimateRope() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
| Member | What it is |
|---|---|
bool AutoRegenerate | Editor option to rebuild the rope when settings change. |
UltimateRope.EAxis BoneAxis | Axis along each imported bone, for ImportBones ropes. |
float BoneColliderDiameter | Collider diameter for imported bones. |
float BoneColliderLength | Collider length as a fraction of each imported bone's length. |
float BoneColliderOffset | Collider offset along the bone, as a fraction of the collider length. |
int BoneColliderSkip | Copied to each node's collider skip count, probably how many links to skip between colliders. |
UltimateRope.EColliderType BoneColliderType | Collider shape for imported bones. Default capsule. |
GameObject BoneFirst | First bone of an imported bone chain. Its name must end in digits. |
GameObject BoneLast | Last bone of an imported bone chain. Its name must end in digits. |
string BoneListNamesNoColliders | Comma list of bone numbers or ranges (like 1-3) that get no collider. |
string BoneListNamesStatic | Comma list of bone numbers or ranges that stay static. |
UltimateRope.EAxis CoilAxisRight | Coil object axis the coil turns around. Default x. |
UltimateRope.EAxis CoilAxisUp | Coil object up axis. Default y. |
float CoilDiameter | Diameter of the coil's core. |
int CoilNumBones | Number of bones used to wrap rope around the coil. Default 50. |
GameObject CoilObject | Object the rope winds around when HasACoil is on. |
float CoilWidth | Width of the coil across its axis. |
bool Deleted | True when the rope has no generated links; setup methods skip deleted ropes. |
bool EnablePrefabUsage | Rope editor option for saving the rope in a prefab. Not read by game code. |
GameObject EventsObjectReceiver | Object that gets OnBreakMethodName sent to it when a link breaks. |
float ExtensibleLength | Maximum extra length an extensible rope can pay out. |
bool HasACoil | Whether an extensible procedural rope winds onto CoilObject. |
UltimateRope.RopeBone[] ImportedBones | The bone chain used by an ImportBones rope. |
bool IsExtensible | Whether the rope can be extended at runtime with ExtendRope. |
UltimateRope.EAxis LinkAxis | Axis along the link mesh, for linked-object ropes. Default z. |
float LinkJointAngularXLimit | Joint swing limit in degrees around x. Zero locks it. |
float LinkJointAngularYLimit | Joint swing limit in degrees around y. Zero locks it. |
float LinkJointAngularZLimit | Joint twist limit in degrees around z. Zero locks it. |
float LinkJointBreakForce | Force at which link joints break (infinite by default). |
float LinkJointBreakTorque | Torque at which link joints break (infinite by default). |
float LinkJointDamperValue | Damper of the joints' angular drive. |
float LinkJointMaxForceValue | Maximum force of the joints' angular drive. |
float LinkJointSpringValue | Spring strength of the joints' angular drive. |
float[] LinkLengths | Length of each link in order, filled when the rope is built. |
float LinkMass | Mass of each link rigidbody. |
GameObject LinkObject | Prefab used for each link of a linked-objects rope. |
float LinkOffsetObject | Gap between linked objects, as a fraction of segment length. |
int LinkSolverIterationCount | Physics solver iterations for each link rigidbody. |
float LinkTwistAngleIncrement | Extra twist in degrees added to each next link, for chain-like ropes. |
float LinkTwistAngleStart | Twist in degrees of the first link object. |
bool LockStartEndInZAxis | Locks each segment's end links to the node rotations instead of aiming them along the segment. |
float[] m_afCoilBoneAngles | Angle of each coil bone around the coil. |
float[] m_afCoilBoneRadiuses | Radius of each coil bone from the coil centre. |
float[] m_afCoilBoneX | Position of each coil bone across the coil's width. |
bool m_bBonesAreImported | Whether the bone chain has been imported. |
bool m_bLastStatusIsError | Whether the last Regenerate failed. Read by IsLastStatusError. |
bool m_bRopeStartInitialOrientationInitialized | Whether the rope start's first position, rotation and scale have been saved. |
float m_fCurrentCoilLength | Length of rope currently wound on the coil. |
float m_fCurrentCoilRopeRadius | Current radius the rope winds at, used to turn coil rotation into length. |
float m_fCurrentCoilTurnsLeft | Turns of rope left on the coil. |
float m_fCurrentExtension | How far the rope is currently extended, between 0 and ExtensibleLength. |
float m_fCurrentExtensionInput | Extension value set from input, starts equal to m_fCurrentExtension. |
int m_nFirstNonCoilNode | Index of the first node that is not the coil: 1 with a coil, 0 without. |
Quaternion m_qInitialRopeStartLocalRot | Saved local rotation of the rope start. |
string m_strAssetFile | Probably the asset file the rope mesh was saved to by the editor. |
string m_strStatus | Last status message. Backing field for Status. |
Vector3 m_v3InitialRopeStartLocalPos | Saved local position of the rope start. |
Vector3 m_v3InitialRopeStartLocalScale | Saved local scale of the rope start. |
string OnBreakMethodName | Method name sent to EventsObjectReceiver with break info when a link breaks. |
bool PersistAfterPlayMode | Rope editor option to keep changes made in play mode. Not read by game code. |
float RopeDiameter | Rope thickness (at least 0.01). |
float RopeDiameterScaleX | Scales the procedural rope's width on x, for flat ropes. At least 0.01. |
float RopeDiameterScaleY | Scales the procedural rope's width on y. At least 0.01. |
int RopeLayer | Layer the rope and its links use. |
Material RopeMaterial | Material for the procedural rope's surface. |
List<UltimateRope.RopeNode> RopeNodes | The rope's segments, each ending at a node object. |
PhysicMaterial RopePhysicsMaterial | Physic material put on link colliders. |
Material RopeSectionMaterial | Material for the procedural rope's end caps and broken ends. |
int RopeSegmentSides | Number of sides around the procedural rope. Default 8. |
GameObject RopeStart | Object the rope starts from. |
float RopeTextureSectionTileMeters | Texture tiling size for the end cap material. |
float RopeTextureTileMeters | Metres of rope per texture repeat along its length. |
UltimateRope.ERopeType RopeType | How the rope is built: procedural mesh, linked objects or imported bones. |
bool SendEvents | Whether link breaks are sent to EventsObjectReceiver. |
int TotalLinks | Number of links across all segments. |
float TotalRopeLength | Length of all segments together. |
Properties
| Member | What it is |
|---|---|
string Status { get; set; } | Message from the last build or change. |
Methods
| Member | What it is |
|---|---|
void AfterImportedBonesObjectRespawn() | Puts imported bones back under the rope (or their non-bone parent if static) after the object respawns. |
void BeforeImportedBonesObjectRespawn() | Puts imported bones back under their original parents before the object respawns. |
GameObject BuildStaticMeshObject(out string strStatusMessage) | Bakes the rope into a static mesh object. Fails in editor play mode; returns a status message. |
bool ChangeRopeDiameter(float fNewDiameter, float fNewScaleX, float fNewScaleY) | Changes a procedural rope's diameter and scale and rebuilds its mesh. False for other rope types. |
bool ChangeRopeSegmentSides(int nNewSegmentSides) | Changes how many sides a procedural rope's cross-section has. False for other rope types. |
void CheckNeedsStartExitLockZ() | For procedural ropes, locks the first and last link of each segment to the node rotations when LockStartEndInZAxis is set. |
void CreateNewNode(int nNode) | Inserts an empty rope node after the given index. |
void DeleteRope(bool bResetNodePositions = false, bool bDestroySkin = true) | Removes the rope's links and joints, optionally resetting node transforms. |
void DeleteRopeLinks() | Destroys the generated link objects. Does nothing for imported bones. |
void ExtendRope(UltimateRope.ERopeExtensionMode eRopeExtensionMode, float fIncrement) | Extends or retracts an extensible rope, linearly or by turning the coil. Logs an error if not allowed. |
void FillLinkMeshIndicesRope(int nLinearLinkIndex, int nTotalLinks, ref int[] indices, bool bBreakable, bool bBrokenLink = false) | Writes the triangle indices for one link's rope surface. For broken links it leaves the gap open. |
void FillLinkMeshIndicesSections(int nLinearLinkIndex, int nTotalLinks, ref int[] indices, bool bBreakable, bool bBrokenLink = false) | Writes the triangle indices for the end caps of a link, or of the whole rope when not breakable. |
bool FirstNodeIsCoil() | Whether the first rope node is the coil. |
bool HasDynamicSegmentNodes() | True if any node object has a non-kinematic rigidbody. |
bool IsLastStatusError() | Whether the last build ended with an error in Status. |
void MoveNodeDown(int nNode) | Swaps a rope node with the next one. |
void MoveNodeUp(int nNode) | Swaps a rope node with the previous one. |
void RecomputeCoil() | Rebuilds the coil bones for the current coil length. |
bool Regenerate(bool bResetNodePositions = false) | Deletes and rebuilds the whole rope. Returns false and sets Status on bad settings. |
void RemoveNode(int nNode) | Removes a rope node. |
void SetupRopeJoints() | Creates the joints between links from the current settings. |
void SetupRopeLinks() | Sets up link colliders, rigidbodies and layer from the current settings. |
void SetupRopeMaterials() | Assigns the rope and section materials on a procedural rope's skinned renderer. |
24 private and internal methods
| Member | What it is |
|---|---|
private void Awake() | In play mode, makes the joints between links, sets up the links, and lays out the coil if the rope has one. |
private bool BuildBoneHashString2GameObject(GameObject goRoot, GameObject goCurrent, ref Dictionary<string, GameObject> outHashString2GameObjects, ref string strErrorMessage) | Maps every object name in a hierarchy to its object, failing if a name is used twice. |
private bool BuildImportedBoneList(GameObject goBoneFirst, GameObject goBoneLast, List<int> ListImportBonesStatic, List<int> ListImportBonesNoCollider, out List<UltimateRope.RopeBone> outListImportedBones, out string strErrorMessage) | Works out the bone name pattern from the first and last bone names and builds the imported bone list. |
private bool BuildImportedBoneListTry(GameObject goRoot, string strPrefix, int nIndexFirst, int nIndexLast, int nDigitsFirst, int nDigitsLast, List<int> ListImportBonesStatic, List<int> ListImportBonesNoCollider, out List<UltimateRope.RopeBone> outListImportedBones, ref string strErrorMessage) | Tries one name pattern and digit count to find each numbered bone, used by BuildImportedBoneList. |
private void CheckAddCoilNode() | For extensible procedural ropes with a coil, inserts a coil node at the start of RopeNodes. |
private void CheckDelCoilNode() | Removes the coil node from the start of RopeNodes if there is one. |
private ConfigurableJoint CreateJoint(GameObject goObject, GameObject goConnectedTo, Vector3 v3Pivot) | Adds a configurable joint to an object, connects it to another's rigidbody and sets its pivot. |
private void CreateRopeJoints(bool bCheckIfBroken = false) | Makes the joints between all links. When asked, skips joints that had broken. |
private float ExtendRopeLinear(float fLinearIncrement) | Moves links in or out of the rope end to extend or retract it, and returns the length actually changed. |
private void FixedUpdate() | Checks for broken joints, cuts the procedural mesh there, sends the break message, and stops the rest of that segment breaking. |
private Vector3 GetAxisVector(UltimateRope.EAxis eAxis, float fLength) | Returns a vector of the given length along an EAxis. |
private int GetLinkAxisIndex() | Returns 0, 1 or 2 for the axis links lie along (x, y or z). |
private Vector3 GetLinkAxisOffset(float fValue) | Returns an offset along the link axis for the rope type. |
private bool GetLinkBoxColliderCenterAndSize(float fLinkLength, float fRopeDiameter, ref Vector3 v3CenterInOut, ref Vector3 v3SizeInOut) | Works out a box collider's centre and size for one link. |
private float GetLinkDiameter() | Returns the rope's thickness: the procedural diameter, the link mesh's width, or the bone collider diameter. |
private Quaternion GetLinkedObjectLocalRotation(float fTwistAngle = 0) | Rotation that lines a link object up with LinkAxis, twisted by an angle. |
private float GetLinkedObjectScale(float fSegmentLength, int nNumLinks) | Scale for link objects so they fill a segment's length, allowing for LinkOffsetObject. |
private void OnGUI() | Empty. |
private bool ParseBoneIndices(string strBoneList, out List<int> outListBoneIndices, out string strErrorMessage) | Parses a comma list of bone numbers and ranges into a list of indices. |
private void SetExtensibleLinkToKinematic(GameObject link, bool bKinematic) | Makes a link kinematic (and unbreakable, collider off) while it is pulled in, or physical again when let out. |
private void SetupCoilBones(float fCoilLength) | Lays the coil node's bones around the coil for a given wound length. |
private void SetupJoint(ConfigurableJoint joint) | Applies the link joint limits, drive and break force settings to a configurable joint. |
private void Start() | Copies the current extension to the extension input. |
private void Update() | Empty. |
Used in
Members of other types that take, return or hold a UltimateRope: