Advertisement
Guest User

Untitled

a guest
Mar 25th, 2014
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. using UnityEngine;
  2. using RootMotion.FinalIK;
  3. using System.Collections;
  4.  
  5. /// <summary>
  6. /// Handles all the IK processing.
  7. /// This runs after Unity's Mecanim and utilises FinalIK asset.
  8. /// It allows for runtime modifications to animations for a better experience (e.g. interacting with the game world while still using motion capture animations)
  9. /// </summary>
  10. public class IKProcessor {
  11.  
  12. private GameObject go;
  13.  
  14. // Final IK
  15. private LookAtIK lookAtIK;
  16. private FullBodyBipedIK fbIK;
  17.  
  18. // Vars
  19. public Vector3 LookAtPos { get; set; }
  20.  
  21. public IKProcessor(GameObject go) {
  22. this.go = go;
  23. lookAtIK = go.GetComponent<LookAtIK>();
  24. fbIK = go.GetComponent<FullBodyBipedIK>();
  25.  
  26. lookAtIK.Disable(); // if this is commented out it works
  27. fbIK.Disable(); // if this is commented out it works
  28. }
  29.  
  30. // This should only be called from a MonoBehaviour.LateUpdate()
  31. public void LateUpdate() {
  32. lookAtIK.solver.IKPositionWeight = 1f;
  33. lookAtIK.solver.IKPosition = LookAtPos;
  34. //Debug.DrawRay(go.transform.position, LookAtPos - go.transform.position);
  35.  
  36. lookAtIK.solver.Update(); // if this is commented out it works
  37. }
  38.  
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement