了解如何动态调整AimIK的“Axis”,以实现武器挥砍动画的重定向。
using UnityEngine;
using System.Collections;
using RootMotion.FinalIK;
namespace RootMotion.Demos {
public class AimSwing : MonoBehaviour {
public AimIK ik;
[Tooltip("The direction of the animated weapon swing in character space. Tweak this value to adjust the aiming.")]
//动画角色在角色空间中摆动的方向。调整这个值来调整瞄准。
public Vector3 animatedSwingDirection = Vector3.forward;
void LateUpdate () {
ik.solver.axis = ik.solver.transform.InverseTransformVector(ik.transform.rotation * animatedSwingDirection);
}
}
}
效果: