Josiahiscool73

roblox3dskill(ihateaistill)

Sep 24th, 2026
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.64 KB | None | 0 0
  1. ---
  2. name: "roblox"
  3. description: "roblox anim"
  4. ---
  5.  
  6. # roblox3d — Skill: Math, CFrame Spaces, and Procedural Rigging That Runs Correctly
  7.  
  8. > **Type:** skill.md
  9. > **Language:** Luau (Roblox)
  10. > **Origin:** Derived from a forensic postmortem of broken procedural R6/R15 joint animators, matrix decomposition errors, and inverted object-space camera scripts that caused limb detachment, gimbal lock, and viewport inversion.
  11.  
  12. ---
  13.  
  14. ## 1. The Prime Directive of 3D Spaces
  15.  
  16. **You cannot add or multiply 3D vectors and matrices based on how they read. You must trace the coordinate spaces.**
  17.  
  18. A 3D engine does not care about your aesthetic intent. If you multiply a local rotation matrix on the wrong side of an offset transformation, the joint will orbit the wrong origin, components will decouple, and characters will deform.
  19.  
  20. Every transformation has a designated home: **World Space**, **Object Space**, or **Joint-Local Space**. Mixing them up without explicit translation is a critical math bug.
  21.  
  22. ---
  23.  
  24. ## 2. Matrix Composition Rules (Non-Negotiable)
  25.  
  26. ### 2.1 CFrame Multiplication is NOT Commutative ($A \times B \neq B \times A$)
  27. The order in which you multiply `CFrame` values dictates the axis and origin of the rotation.
  28.  
  29. ```lua
  30. -- ❌ WRONG: Rotates the joint around the PARENT's axis (Torso alignment)
  31. -- Result: Arm detaches, orbits the stomach, or shears wildly when the torso moves.
  32. motor.C0 = restC0 * CFrame.new(offset) * CFrame.Angles(x, y, z)
  33.  
  34. -- ✅ CORRECT: Rotates the joint around its OWN local socket pivot point
  35. -- Result: Limbs rotate naturally inside their shoulder/hip sockets.
  36. motor.C0 = restC0 * CFrame.Angles(x, y, z) * CFrame.new(offset)
  37. ```
  38. **The Rule:** To transform an object along its **local axes**, multiply the modification `CFrame` to the **right** of the original base (`Base * LocalTransform`). To transform an object along **world/parent axes**, multiply the modification `CFrame` to the **left** (`WorldTransform * Base`).
  39.  
  40. ### 2.2 Never assume identical axes across different rig joints
  41. An angle that represents a "forward tilt" on a head does not mean "forward tilt" on a shoulder. In the standard Roblox R6/R15 configuration, joints are welded with distinct base orientations:
  42. * **Shoulders (Left/Right):** The default primary lifting axis is the local **Z-axis** (bringing the arm from the hip up to the sky). Side-to-side waving occurs along the local **X-axis** once raised.
  43. * **Neck:** The local **X-axis** dictates pitch (looking up/down), the **Y-axis** dictates yaw (looking left/right), and the **Z-axis** dictates roll (tilting the head sideways).
  44.  
  45. **The Rule:** Run a physical diagnostic or use your eyes in Studio to map the exact joint rotation before writing keyframe tables. Never copy-paste `CFrame.Angles` parameters from an arm to a leg or a head expecting the same visual output.
  46.  
  47. ---
  48.  
  49. ## 3. Computational Geometry & Viewport Rules
  50.  
  51. ### 3.1 Clamp camera pitch explicitly to prevent Viewport Inversion
  52. When implementing custom 3D orbit, vehicle, or camera inspection systems, tracking mouse movements across raw Euler angles will cause the camera to flip upside down, invert left/right controls, and induce **Gimbal Lock** if it passes a vertical pole.
  53.  
  54. ```lua
  55. -- ❌ WRONG: Unclamped Euler accumulators cause gimbal flips at the poles
  56. cameraRotation = cameraRotation * CFrame.Angles(mouseDelta.Y, mouseDelta.X, 0)
  57.  
  58. -- ✅ CORRECT: Track raw scalar angles, clamp pitch, and construct cleanly
  59. local maxPitch = math.rad(88) -- Prevent reaching exact vertical 90 degrees
  60. currentPitch = math.clamp(currentPitch - mouseDelta.Y, -maxPitch, maxPitch)
  61. currentYaw = currentYaw - mouseDelta.X
  62.  
  63. camera.CFrame = CFrame.new(targetPosition)
  64. * CFrame.Angles(0, currentYaw, 0)
  65. * CFrame.Angles(currentPitch, 0, 0)
  66. * CFrame.new(0, 0, zoomDistance)
  67. ```
  68.  
  69. ### 3.2 Roblox Grip Welds assume spatial inversion (The Wrist Trap)
  70. When scripting tools, visual attachments, or custom weapon grips, remember:
  71. * In modeling suites like **Blender**, characters stand upright on the **+Z axis**, and tools are traditionally modeled pointing upward along **+Y**.
  72. * In **Roblox**, the engine's internal `RightGrip` weld forces a hardcoded $-\frac{\pi}{2}$ ($90^\circ$) pitch at the hand socket, assuming items extend outward along the **-Z axis**.
  73.  
  74. **The Rule:** When bridging raw assets between Blender and Luau procedural code, you must inject an explicit compensation matrix (`CFrame.Angles(math.rad(-90), 0, 0)`) to re-align tool geometries to the hand container.
  75.  
  76. ---
  77.  
  78. ## 4. Performance & Lifecycle Invariants
  79.  
  80. ### 4.1 Frame updates must carry explicit death plans
  81. Any script manipulating raw `Motor6D.C0`, `Camera.CFrame`, or structural 3D vectors via high-frequency event connections (`RenderStepped`, `Heartbeat`) will leak processing memory and crash threads if it is not unlinked when instances are cleared.
  82.  
  83. ```lua
  84. -- ✅ Ensure loop lifecycle terminates when character resets or object is destroyed
  85. local connection
  86. connection = RunService.Heartbeat:Connect(function(dt)
  87. if not character:IsDescendantOf(workspace) or not humanoid or humanoid.Health <= 0 then
  88. connection:Disconnect()
  89. return
  90. end
  91. -- Apply 3D math here safely
  92. end)
  93. ```
  94.  
  95. ### 4.2 Cache rest states once; never read structural states on the hot path
  96. Reading properties like `Motor6D.Transform`, `Joint.C0`, or spatial parameters from the data model inside an frame loop triggers an implicit execution cost, causing serious physics engine lag.
  97.  
  98. * **Pure Data Rule:** Cache the original `RestC0` states into memory **once** at script startup. Use your mathematical adjustments against the stored data table, and push the calculations to the instances *exactly once per frame*.
  99.  
  100. ### 4.3 * **Hips vs. Shoulders Inversion:** Hip joints are mirrored relative to shoulders on standard rigs. Applying identical angular modifications (`CFrame.Angles`) to both will cause legs to cross over or invert. Always invert the roll/yaw sign or map hip pitch to the opposing local axis coordinate.
  101.  
  102. ---
  103.  
  104. ## 5. Summary Mechanical Checklist
  105.  
  106. - [ ] **Pivot Order:** Verify custom joint angles are multiplied before translations (`Rest * Angles * Offset`).
  107. - [ ] **Axis Validation:** Explicitly test if `X`, `Y`, or `Z` drives the intended movement for that specific joint before hardcoding interpolation tables.
  108. - [ ] **Gimbal Protection:** Check that camera pitch trackers are strictly clamped between roughly $-88^\circ$ and $+88^\circ$ to prevent viewport flipping.
  109. - [ ] **Clean Disposal:** Ensure all frame loops feature a verification check that disconnects the engine sequence when the player or rig leaves the active workspace tree.
  110.  
Advertisement
Add Comment
Please, Sign In to add comment