InteractionC2CDemo.cs 972 B

123456789101112131415161718192021222324252627282930313233
  1. using UnityEngine;
  2. using System.Collections;
  3. using RootMotion.FinalIK;
  4. namespace RootMotion.Demos {
  5. /// <summary>
  6. /// Demonstrating character-character FBBIK interaction.
  7. /// </summary>
  8. public class InteractionC2CDemo : MonoBehaviour {
  9. // GUI for testing
  10. void OnGUI() {
  11. if (GUILayout.Button("Shake Hands")) {
  12. character1.StartInteraction(FullBodyBipedEffector.RightHand, handShake, true);
  13. character2.StartInteraction(FullBodyBipedEffector.RightHand, handShake, true);
  14. }
  15. }
  16. public InteractionSystem character1, character2; // The InteractionSystems of the characters
  17. public InteractionObject handShake; // The HandShake InteractionObject
  18. void LateUpdate() {
  19. // Positioning the handshake to the middle of the hands
  20. Vector3 handsCenter = Vector3.Lerp(character1.ik.solver.rightHandEffector.bone.position, character2.ik.solver.rightHandEffector.bone.position, 0.5f);
  21. handShake.transform.position = handsCenter;
  22. }
  23. }
  24. }