| %YAML 1.1 |
| %TAG !u! tag:unity3d.com,2011: |
| --- !u!114 &11400000 |
| MonoBehaviour: |
| m_ObjectHideFlags: 0 |
| m_CorrespondingSourceObject: {fileID: 0} |
| m_PrefabInstance: {fileID: 0} |
| m_PrefabAsset: {fileID: 0} |
| m_GameObject: {fileID: 0} |
| m_Enabled: 1 |
| m_EditorHideFlags: 0 |
| m_Script: {fileID: 11500000, guid: 4510294d23d964fe59443526f1ca7c4b, type: 3} |
| m_Name: Rope |
| m_EditorClassIdentifier: |
| m_displayName: Rope |
| m_hierarchyName: Rope |
| m_context: {fileID: 11400000, guid: 0213ac5a1a4e20343897a54b5d658570, type: 2} |
| m_markdownFile: {fileID: 0} |
| m_priority: 1010 |
| m_overrideMarkdownText: "# Rope System\n\nNorthStar's development prioritized creating |
| a realistic rope simulation system. We achieved this by combining Verlet integration |
| for simulation with anchoring constraints for interactive rope behavior.\n\n## |
| Verlet Simulation\n\n\n\nVerlet integration |
| simplifies rope physics by focusing on point mass calculations. Each point mass |
| stores only its current and previous positions, assuming a unit mass. Constraints |
| are enforced by adjusting point positions to maintain the rope's rest length.\n\nThis |
| approach simulates how ropes visually react to player interactions. However, |
| forces only travel from the player to the rope, not bidirectionally.\n\nTo enhance |
| stability, we implemented a binding system. This system allows specific nodes |
| in the rope simulation to act as kinematic points, unaffected by forces or constraints. |
| We optimized the Verlet simulation using Burst Jobs to support many nodes and |
| high iteration counts for constraint solving.\n\n### Relevant Files\n- [BurstRope.cs](https://github.com/meta-quest/Unity-UtilityPackages/blob/main/com.meta.utilities.ropes/Runtime/Rope/VerletRope/BurstRope.cs)\n\n## |
| Anchoring Constraints\n\nWe developed an anchoring system to let players interact |
| with and be constrained by ropes. This system enables ropes to wrap around static |
| objects, dynamically creating bends that constrain the Verlet simulation.\n\n**How |
| Anchors Work:**\n\n- When the rope encounters an obstacle, a new anchor is created |
| based on normal direction, bend angle, and bend direction.\n- If the player holds |
| the rope, the system calculates the rope length between two anchors and applies |
| a configurable joint with a linear limit to prevent overstretching.\n- Slack |
| and spooled rope are managed, allowing:\n - Loose rope to be pulled through |
| when tightening.\n - Extra rope to be spooled out, such as for sail controls.\n- |
| If the player exerts enough force, the rope can slip, allowing hands to slide |
| along it like a real rope.\n- The number of bends, slack amount, and spooled |
| rope length can trigger events when the rope is pulled tight or tied.\n\n### |
| Relevant Files\n- [RopeSystem.cs](https://github.com/meta-quest/Unity-UtilityPackages/blob/main/com.meta.utilities.ropes/Runtime/Rope/RopeSystem.cs)\n\n## |
| Tube Rendering\n\n\n\nTo render ropes visually, |
| we developed a tube renderer that:\n\n- Uses rope nodes to generate a lofted |
| mesh along a spline.\n- Supports subdivisions for added detail.\n- Adds indentation |
| and twisting for realism.\n- Utilizes normal mapping for enhanced depth and texture.\n- |
| Is optimized using Burst Jobs for efficient performance.\n\n### Relevant Files\n- |
| [TubeRenderer.cs](https://github.com/meta-quest/Unity-UtilityPackages/blob/main/com.meta.utilities.ropes/Runtime/Rope/VerletRope/TubeRenderer.cs)\n\n## |
| Collision Detection\n\n\n\nEfficient rope collision |
| detection was challenging. We used `Physics.ComputePenetration()` to detect interactions |
| between Verlet nodes and nearby level geometry. However, two key issues arose:\n1. |
| `ComputePenetration` is incompatible with Jobs or Burst, so collision detection |
| had to occur on the main thread after Verlet simulation.\n2. Single collision |
| checks per frame caused phasing issues, as ropes passed through objects when |
| nodes were forced apart.\n\n**Optimizations for Better Collision Detection:**\n\nTo |
| address these issues, we:\n- Split the rope simulation into multiple sub-steps, |
| running a collision check after each sub-step.\n- Forced the first job to complete |
| immediately, allowing for early collision checks in the frame.\n- Performed the |
| second sub-step during the frame, resolving it in `LateUpdate()` for increased |
| stability.\n- Used `SphereOverlapCommand` in a Job to efficiently gather potential |
| collisions without stalling the main thread.\n\n### Relevant Files\n- [BurstRope.cs](https://github.com/meta-quest/Unity-UtilityPackages/blob/main/com.meta.utilities.ropes/Runtime/Rope/VerletRope/BurstRope.cs)\n\n## |
| Editor Workflow\n\n\n\nWe streamlined the process |
| of adding and configuring ropes in scenes with an intuitive editor workflow:\n- |
| Start with the `RopeSystem` prefab.\n- Edit the included spline to define the |
| desired rope shape.\n- Use context menu options in the `RopeSystem` component |
| to:\n - Set up nodes.\n - Define the rope's total length.\n- Run the simulation |
| in a test scene and allow the rope to settle naturally.\n- Copy the anchor points |
| and `BurstRope` nodes from the simulation back into the editor.\n- Finalize the |
| rope setup for use in live gameplay.\n\n\n\n### |
| Relevant Files\n- [RopeSystem.prefab](../Assets/NorthStar/Prefabs/RopeSystem.prefab)\n\n## |
| Conclusion\n\nBy combining Verlet simulation with dynamic anchoring constraints, |
| we created a realistic and performant rope system for NorthStar. The use of Burst |
| Jobs, tube rendering, and multi-step collision detection balanced realism, interactivity, |
| and performance. The editor workflow streamlined development, enabling efficient |
| iteration and fine-tuning of rope behaviors.\n" |
| m_overrideMarkdownRoot: .\Documentation/ |
|
|