Fixing animation blending and aim

Using mixamo-style skeleton.


Using a blendtree. Just to show it work with blendtree

Blend filter:

Problem: When aiming the children follow rotation of parent, impossible to have proper aim offset like in Unreal Engine.


The fix: Cancel pelvis rotation by rotating spline_01
Do this in process, after the blendtree is processed.

func _process(delta: float) -> void:
	if controller.state == "aim":
		var pelvis_global_rot = skeleton.get_bone_global_pose(pelvis_idx).basis.get_rotation_quaternion()
		skeleton.set_bone_pose_rotation(spine_01_idx, pelvis_global_rot.inverse())

Result: Now Upper body always face forward.


Fine tune: Add offset (previous image the player aim too much on the left, because of other bones rotations)

func _process(delta: float) -> void:
	if controller.state == "aim":
		var pelvis_global_rot = skeleton.get_bone_global_pose(pelvis_idx).basis.get_rotation_quaternion()
		var offset_rot = Quaternion(Vector3.UP, deg_to_rad(-20.0))
		skeleton.set_bone_pose_rotation(spine_01_idx, pelvis_global_rot.inverse() * offset_rot)