Advertisement
Guest User

Final_IK_Edited_Script

a guest
Jun 7th, 2016
298
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.08 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3. using RootMotion.FinalIK;
  4.  
  5. #if UNITY_EDITOR
  6. using UnityEditor;
  7. #endif
  8.  
  9. namespace AC
  10. {
  11.     [System.Serializable]
  12.     public class FinalIK_RunInteraction : Action
  13.     {
  14.         public bool isPlayer;
  15.         public InteractionSystem interactionSystem;
  16.         public FullBodyBipedEffector effector;
  17.         public InteractionObject interactionObject;
  18.         public bool canInterrupt;
  19.        
  20.         public FinalIK_RunInteraction()
  21.         {
  22.             this.isDisplayed = true;
  23.             category = ActionCategory.Custom;
  24.             title = "Final IK - Run interaction";
  25.             description = "Starts an interaction using the Final IK Interaction System";
  26.             isPlayer = true;
  27.             canInterrupt = true;
  28.         }
  29.        
  30.         override public float Run()
  31.         {
  32.             if (isPlayer)
  33.             {
  34.                 interactionSystem = KickStarter.player.GetComponent<InteractionSystem>();
  35.                
  36.                 if (interactionSystem == null)
  37.                 {
  38.                     Debug.LogWarning("FinalIK_RunInteraction: No InteractionSystem found on Player.");
  39.                     return 0f;
  40.                 }
  41.             }
  42.             else if (interactionSystem == null)
  43.             {
  44.                 Debug.LogWarning("FinalIK_RunInteraction: No InteractionSystem defined.");
  45.                 return 0f;
  46.             }
  47.            
  48.             if (interactionObject == null)
  49.             {
  50.                 Debug.LogWarning("FinalIK_RunInteraction: No InteractionObject defined.");
  51.                 return 0f;
  52.             }
  53.            
  54.             interactionSystem.StartInteraction(effector, interactionObject, canInterrupt);
  55.             return 0f;
  56.         }
  57.  
  58.         override public void Skip(){
  59.  
  60.  
  61.        
  62.  
  63.  
  64.         }
  65.  
  66.  
  67.        
  68.         #if UNITY_EDITOR
  69.         override public void ShowGUI()
  70.         {
  71.             isPlayer = EditorGUILayout.Toggle("Is player?", isPlayer);
  72.            
  73.             if (!isPlayer)
  74.             {
  75.                 interactionSystem = (InteractionSystem)EditorGUILayout.ObjectField("Character:", interactionSystem, typeof(InteractionSystem), true);
  76.             }
  77.            
  78.             effector = (FullBodyBipedEffector)EditorGUILayout.EnumPopup("Effector:", effector);
  79.            
  80.             interactionObject = (InteractionObject)EditorGUILayout.ObjectField("Interaction object:", interactionObject, typeof(InteractionObject), true);
  81.             canInterrupt = EditorGUILayout.Toggle("Can interrupt?", canInterrupt);
  82.             AfterRunningOption();
  83.         }
  84.         #endif
  85.     }
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement