Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using RootMotion.FinalIK;
- using System.Collections;
- /// <summary>
- /// Handles all the IK processing.
- /// This runs after Unity's Mecanim and utilises FinalIK asset.
- /// It allows for runtime modifications to animations for a better experience (e.g. interacting with the game world while still using motion capture animations)
- /// </summary>
- public class IKProcessor {
- private GameObject go;
- // Final IK
- private LookAtIK lookAtIK;
- private FullBodyBipedIK fbIK;
- // Vars
- public Vector3 LookAtPos { get; set; }
- public IKProcessor(GameObject go) {
- this.go = go;
- lookAtIK = go.GetComponent<LookAtIK>();
- fbIK = go.GetComponent<FullBodyBipedIK>();
- lookAtIK.Disable(); // if this is commented out it works
- fbIK.Disable(); // if this is commented out it works
- }
- // This should only be called from a MonoBehaviour.LateUpdate()
- public void LateUpdate() {
- lookAtIK.solver.IKPositionWeight = 1f;
- lookAtIK.solver.IKPosition = LookAtPos;
- //Debug.DrawRay(go.transform.position, LookAtPos - go.transform.position);
- lookAtIK.solver.Update(); // if this is commented out it works
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement