All MicroEvals
Lua Roblox test
Create MicroEval

Lua Roblox test

Prompt

Write a complete, production-ready, client-side Roblox Luau script (LocalScript intended for StarterCharacterScripts) that implements a procedural Two-Bone Inverse Kinematics (Two-Bone IK) Foot Planting system for standard R15 character rigs. When the player walks on uneven terrain, stairs, or slopes, their feet must dynamically and smoothly adapt to the ground surface instead of floating in the air or clipping into geometry. STRICT TECHNICAL REQUIREMENTS: 1. Character Rig & Joint Manipulation: - Target standard R15 rigs (manipulating LeftUpperLeg, LeftLowerLeg, LeftFoot, RightUpperLeg, RightLowerLeg, RightFoot, and RootJoint). - Manipulate joints cleanly via Motor6D.Transform (or modern animated joint manipulation) inside RunService.Stepped / RenderStepped so it blends naturally on top of existing walking/idle animations without overriding core animation tracks. 2. Two-Bone Analytical IK Solver: - Implement an analytical 2-bone IK solver using the Law of Cosines (c^2 = a^2 + b^2 - 2ab \cos C). - Upper leg length L_1 and lower leg length L_2 must be dynamically derived from the character's Motor6D offsets (or bone distances) so it scales with any character size. - Enforce proper knee bending: the knee MUST bend forward naturally and never flip backwards or twist sideways. 3. Terrain Raycasting & Surface Alignment: - Raycast downward from each hip/foot position to detect ground surface beneath each leg. - Align each foot's rotation with the hit surface normal so the sole of the foot rests flat against slopes and stairs. 4. Dynamic Pelvis / Hip Drop: - If one foot needs to step on lower ground than the character's root position, lower the character's pelvis/hip offset (RootJoint) downward so the lower leg can reach the floor without hyper-extending the higher leg. 5. Smoothing & State Safety: - Use delta-time-dependent smoothing (e.g., exponential smoothing or spring lerping) to prevent jarring snaps when stepping on/off ledges. - Fade out IK weight automatically when jumping, falling, or in freefall (Humanoid:GetState()). - Clean up on character death/respawn. Output only a single complete, robust LocalScript with strict Luau typing (--!strict) and zero placeholder comments.

Drag to resize

Response not available

Drag to resize

Response not available

Drag to resize
Drag to resize