AimBoxing.cs 800 B

1234567891011121314151617181920212223242526
  1. using UnityEngine;
  2. using System.Collections;
  3. using RootMotion.FinalIK;
  4. namespace RootMotion.Demos {
  5. /// <summary>
  6. /// Boxing with Aim IK.
  7. /// Changing character facing direction with Aim IK to follow the target.
  8. /// </summary>
  9. public class AimBoxing : MonoBehaviour {
  10. public AimIK aimIK; // Reference to the AimIK component
  11. public Transform pin; // The hitting point as in the animation
  12. void LateUpdate() {
  13. // Rotate the aim Transform to look at the point, where the fist hits it's target in the animation.
  14. // This will set the animated hit direction as the default starting point for Aim IK (direction for which Aim IK has to do nothing).
  15. aimIK.solver.transform.LookAt(pin.position);
  16. // Set myself as IK target
  17. aimIK.solver.IKPosition = transform.position;
  18. }
  19. }
  20. }