feat: Implement facing profiles and bend direction toggles in test harness

- Added functionality for skeleton IK bone switches, allowing users to dynamically change the bend direction of joints via a context menu.
- Introduced facing profiles (LEFT, RIGHT, FORWARD) that modify the bend direction of limbs based on the selected profile.
- Implemented body part z-ordering based on the facing profile, ensuring correct rendering order of limbs relative to the torso.
- Added a coordinates display panel that shows the position and rotation of the Skeleton2D and its bones, as well as IK target positions.
- Created a new script to generate a walk animation for the stickman rig, including keyframe tracks for various IK targets.
- Updated documentation to reflect the new features and their specifications.
This commit is contained in:
2026-08-23 22:21:23 -04:00
parent ab5c79ab6a
commit 273090993e
9 changed files with 1013 additions and 26 deletions
+60
View File
@@ -0,0 +1,60 @@
@tool
extends Node2D
@export var build_walk_animation: bool = false:
set(value):
if value:
_create_walk_right_animation()
func _create_walk_right_animation() -> void:
var anim_player: AnimationPlayer = get_node_or_null("AnimationPlayer")
if not anim_player:
push_error("AnimationPlayer node not found as direct child of Master!")
return
var anim = Animation.new()
anim.length = 0.8
anim.loop_mode = Animation.LOOP_LINEAR
var times = [0.0, 0.2, 0.4, 0.6, 0.8]
# Keyframe tracks mapped relative to root Master node
var tracks = {
"IK_Targets/Torso:position": [
Vector2(0, 10), Vector2(0, -15), Vector2(0, 10), Vector2(0, -15), Vector2(0, 10)
],
"IK_Targets/Head:position": [
Vector2(100, -614), Vector2(100, -639), Vector2(100, -614), Vector2(100, -639), Vector2(100, -614)
],
"IK_Targets/Right_Leg:position": [
Vector2(110, 390), Vector2(0, 397), Vector2(-110, 380), Vector2(-20, 320), Vector2(110, 390)
],
"IK_Targets/Left_Leg:position": [
Vector2(-110, 380), Vector2(-20, 320), Vector2(110, 390), Vector2(0, 397), Vector2(-110, 380)
],
"IK_Targets/Right_Hand:position": [
Vector2(-90, 110), Vector2(0, 115), Vector2(90, 110), Vector2(0, 115), Vector2(-90, 110)
],
"IK_Targets/Left_Hand:position": [
Vector2(90, 110), Vector2(0, 115), Vector2(-90, 110), Vector2(0, 115), Vector2(-90, 110)
]
}
for path in tracks:
var track_idx = anim.add_track(Animation.TYPE_VALUE)
anim.track_set_path(track_idx, path)
anim.track_set_interpolation_type(track_idx, Animation.INTERPOLATION_CUBIC)
for i in range(times.size()):
anim.track_insert_key(track_idx, times[i], tracks[path][i])
# Add or retrieve default library
var lib = anim_player.get_animation_library("")
if not lib:
lib = AnimationLibrary.new()
anim_player.add_animation_library("", lib)
if lib.has_animation("walk_right"):
lib.remove_animation("walk_right")
lib.add_animation("walk_right", anim)
print("✓ Successfully generated 'walk_right' animation in AnimationPlayer!")